1 ; The goal of the test is to check that newly inserted `ptrcast` internal
2 ; intrinsic functions for PHI's operands are inserted at the correct
3 ; positions, and don't break rules of instruction domination and PHI nodes
4 ; grouping at top of basic block.
6 ; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s
7 ; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %}
9 ; CHECK-DAG: OpName %[[#Case1:]] "case1"
10 ; CHECK-DAG: OpName %[[#Case2:]] "case2"
11 ; CHECK-DAG: OpName %[[#Case3:]] "case3"
12 ; CHECK: %[[#Case1]] = OpFunction
13 ; CHECK: OpBranchConditional
16 ; CHECK-COUNT-2: OpBranchConditional
17 ; CHECK: OpFunctionEnd
18 ; CHECK: %[[#Case2]] = OpFunction
19 ; CHECK: OpBranchConditional
22 ; CHECK-COUNT-2: OpBranchConditional
23 ; CHECK: OpFunctionEnd
24 ; CHECK: %[[#Case3]] = OpFunction
25 ; CHECK: OpBranchConditional
28 ; CHECK: OpInBoundsPtrAccessChain
29 ; CHECK: OpBranchConditional
30 ; CHECK: OpInBoundsPtrAccessChain
31 ; CHECK: OpBranchConditional
32 ; CHECK: OpFunctionEnd
34 %struct1 = type { i64 }
35 %struct2 = type { i64, i64 }
37 @.str.1 = private unnamed_addr addrspace(1) constant [3 x i8] c"OK\00", align 1
38 @.str.2 = private unnamed_addr addrspace(1) constant [6 x i8] c"WRONG\00", align 1
40 define spir_func void @case1(i1 %b1, i1 %b2, i1 %b3) {
42 br i1 %b1, label %l1, label %l2
45 %str = phi ptr addrspace(1) [ @.str.1, %entry ], [ @.str.2, %l2 ], [ @.str.2, %l3 ]
49 br i1 %b2, label %l1, label %l3
52 br i1 %b3, label %l1, label %exit
58 define spir_func void @case2(i1 %b1, i1 %b2, i1 %b3, ptr addrspace(1) byval(%struct1) %str1, ptr addrspace(1) byval(%struct2) %str2) {
60 br i1 %b1, label %l1, label %l2
63 %str = phi ptr addrspace(1) [ %str1, %entry ], [ %str2, %l2 ], [ %str2, %l3 ]
67 br i1 %b2, label %l1, label %l3
70 br i1 %b3, label %l1, label %exit
76 define spir_func void @case3(i1 %b1, i1 %b2, i1 %b3, ptr addrspace(1) byval(%struct1) %_arg_str1, ptr addrspace(1) byval(%struct2) %_arg_str2) {
78 br i1 %b1, label %l1, label %l2
81 %str = phi ptr addrspace(1) [ %_arg_str1, %entry ], [ %str2, %l2 ], [ %str3, %l3 ]
85 %str2 = getelementptr inbounds %struct2, ptr addrspace(1) %_arg_str2, i32 1
86 br i1 %b2, label %l1, label %l3
89 %str3 = getelementptr inbounds %struct2, ptr addrspace(1) %_arg_str2, i32 2
90 br i1 %b3, label %l1, label %exit