File: phi-ptrcast-dominate.ll

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 1,998,492 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (94 lines) | stat: -rw-r--r-- 2,561 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
; The goal of the test is to check that newly inserted `ptrcast` internal
; intrinsic functions for PHI's operands are inserted at the correct
; positions, and don't break rules of instruction domination and PHI nodes
; grouping at top of basic block.

; RUN: llc -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-DAG: OpName %[[#Case1:]] "case1"
; CHECK-DAG: OpName %[[#Case2:]] "case2"
; CHECK-DAG: OpName %[[#Case3:]] "case3"
; CHECK: %[[#Case1]] = OpFunction
; CHECK: OpBranchConditional
; CHECK: OpPhi
; CHECK: OpBranch
; CHECK-COUNT-2: OpBranchConditional
; CHECK: OpFunctionEnd
; CHECK: %[[#Case2]] = OpFunction
; CHECK: OpBranchConditional
; CHECK: OpPhi
; CHECK: OpBranch
; CHECK-COUNT-2: OpBranchConditional
; CHECK: OpFunctionEnd
; CHECK: %[[#Case3]] = OpFunction
; CHECK: OpBranchConditional
; CHECK: OpPhi
; CHECK: OpBranch
; CHECK: OpInBoundsPtrAccessChain
; CHECK: OpBranchConditional
; CHECK: OpInBoundsPtrAccessChain
; CHECK: OpBranchConditional
; CHECK: OpFunctionEnd

%struct1 = type { i64 }
%struct2 = type { i64, i64 }

@.str.1 = private unnamed_addr addrspace(1) constant [3 x i8] c"OK\00", align 1
@.str.2 = private unnamed_addr addrspace(1) constant [6 x i8] c"WRONG\00", align 1

define spir_func void @case1(i1 %b1, i1 %b2, i1 %b3) {
entry:
  br i1 %b1, label %l1, label %l2

l1:
  %str = phi ptr addrspace(1) [ @.str.1, %entry ], [ @.str.2, %l2 ], [ @.str.2, %l3 ]
  br label %exit

l2:
  br i1 %b2, label %l1, label %l3

l3:
  br i1 %b3, label %l1, label %exit

exit:
  ret void
}

define spir_func void @case2(i1 %b1, i1 %b2, i1 %b3, ptr addrspace(1) byval(%struct1) %str1, ptr addrspace(1) byval(%struct2) %str2) {
entry:
  br i1 %b1, label %l1, label %l2

l1:
  %str = phi ptr addrspace(1) [ %str1, %entry ], [ %str2, %l2 ], [ %str2, %l3 ]
  br label %exit

l2:
  br i1 %b2, label %l1, label %l3

l3:
  br i1 %b3, label %l1, label %exit

exit:
  ret void
}

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) {
entry:
  br i1 %b1, label %l1, label %l2

l1:
  %str = phi ptr addrspace(1) [ %_arg_str1, %entry ], [ %str2, %l2 ], [ %str3, %l3 ]
  br label %exit

l2:
  %str2 = getelementptr inbounds %struct2, ptr addrspace(1) %_arg_str2, i32 1
  br i1 %b2, label %l1, label %l3

l3:
  %str3 = getelementptr inbounds %struct2, ptr addrspace(1) %_arg_str2, i32 2
  br i1 %b3, label %l1, label %exit

exit:
  ret void
}