1 ; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s
2 ; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s
4 ; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv32-unknown-unknown --translator-compatibility-mode %s -o - -filetype=obj | spirv-val %}
5 ; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv32-unknown-unknown %s -o - -filetype=obj | spirv-val %}
6 ; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown --translator-compatibility-mode %s -o - -filetype=obj | spirv-val %}
7 ; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %}
9 ; CHECK-DAG: %[[Char:.*]] = OpTypeInt 8 0
10 ; CHECK-DAG: %[[Long:.*]] = OpTypeInt 32 0
11 ; CHECK-DAG: %[[Array:.*]] = OpTypeArray %[[Long]] %[[#]]
12 ; CHECK-DAG: %[[Struct:.*]] = OpTypeStruct %[[Array]]
13 ; CHECK-DAG: %[[StructPtr:.*]] = OpTypePointer Function %[[Struct]]
14 ; CHECK-DAG: %[[CharPtr:.*]] = OpTypePointer Function %[[Char]]
16 ; CHECK: %[[Branch1:.*]] = OpLabel
17 ; CHECK: %[[Res1:.*]] = OpVariable %[[StructPtr]] Function
18 ; CHECK: OpBranchConditional %[[#]] %[[#]] %[[Branch2:.*]]
19 ; CHECK: %[[Res2:.*]] = OpInBoundsPtrAccessChain %[[CharPtr]] %[[#]] %[[#]]
20 ; CHECK: %[[Res2Casted:.*]] = OpBitcast %[[StructPtr]] %[[Res2]]
21 ; CHECK: OpBranchConditional %[[#]] %[[#]] %[[BranchSelect:.*]]
22 ; CHECK: %[[SelectRes:.*]] = OpSelect %[[CharPtr]] %[[#]] %[[#]] %[[#]]
23 ; CHECK: %[[SelectResCasted:.*]] = OpBitcast %[[StructPtr]] %[[SelectRes]]
25 ; CHECK: OpPhi %[[StructPtr]] %[[Res1]] %[[Branch1]] %[[Res2Casted]] %[[Branch2]] %[[SelectResCasted]] %[[BranchSelect]]
27 %struct = type { %array }
28 %array = type { [1 x i64] }
29 %array3 = type { [3 x i32] }
31 define spir_kernel void @foo(ptr addrspace(1) noundef align 1 %arg1, ptr noundef byval(%struct) align 8 %arg2, i1 noundef zeroext %expected) {
33 %agg = alloca %array3, align 8
34 %r0 = load i64, ptr %arg2, align 8
35 %add.ptr = getelementptr inbounds i8, ptr %agg, i64 12
36 %r1 = load i32, ptr %agg, align 4
37 %tobool0 = icmp slt i32 %r1, 0
38 br i1 %tobool0, label %exit, label %sw1
41 %incdec1 = getelementptr inbounds i8, ptr %agg, i64 4
42 %r2 = load i32, ptr %incdec1, align 4
43 %tobool1 = icmp slt i32 %r2, 0
44 br i1 %tobool1, label %exit, label %sw2
47 %incdec2 = getelementptr inbounds i8, ptr %agg, i64 8
48 %r3 = load i32, ptr %incdec2, align 4
49 %tobool2 = icmp slt i32 %r3, 0
50 %spec.select = select i1 %tobool2, ptr %incdec2, ptr %add.ptr
53 exit: ; preds = %sw2, %sw1, %entry
54 %retval.0 = phi ptr [ %agg, %entry ], [ %incdec1, %sw1 ], [ %spec.select, %sw2 ]
55 %add.ptr.i = getelementptr inbounds i8, ptr addrspace(1) %arg1, i64 %r0
56 %r4 = icmp eq ptr %retval.0, %add.ptr
57 %cmp = xor i1 %r4, %expected
58 %frombool6.i = zext i1 %cmp to i8
59 store i8 %frombool6.i, ptr addrspace(1) %add.ptr.i, align 1
60 %r5 = icmp eq ptr %add.ptr, %retval.0