llvm-project/llvm/test/CodeGen/SPIRV/instructions/insertvalue-undef-ptr.ll
Tim Besard 58805dd9ed
[SPIRV] Fix type mismatch assertion in insertvalue. (#143131)
The code was incorrectly converting all `undef` arguments to `i32`,
while the `spv_insertv` intrinsics only expects that for the first
operand, representing the aggregate type.

Fixes https://github.com/llvm/llvm-project/issues/127977

---------

Co-authored-by: Michal Paszkowski <michal@michalpaszkowski.com>
2025-09-28 04:13:41 -07:00

29 lines
929 B
LLVM

; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %}
; CHECK-LABEL: Begin function original_testcase
define fastcc void @original_testcase() {
top:
; CHECK: OpCompositeInsert
%0 = insertvalue [1 x ptr] zeroinitializer, ptr poison, 0
ret void
}
; CHECK-LABEL: Begin function additional_testcases
define fastcc void @additional_testcases() {
top:
; Test with different pointer types
; CHECK: OpCompositeInsert
%1 = insertvalue [1 x ptr] zeroinitializer, ptr undef, 0
; CHECK-NEXT: OpCompositeInsert
%2 = insertvalue {ptr, i32} zeroinitializer, ptr poison, 0
; CHECK-NEXT: OpCompositeInsert
%3 = insertvalue {ptr, ptr} undef, ptr null, 0
; Test with undef aggregate
; CHECK-NEXT: OpCompositeInsert
%4 = insertvalue [1 x ptr] undef, ptr undef, 0
ret void
}