annotate llvm/test/CodeGen/AMDGPU/divergent-branch-uniform-condition.ll @ 266:00f31e85ec16 default tip

Added tag current for changeset 31d058e83c98
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 14 Oct 2023 10:13:55 +0900
parents c4bab56944e8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
2
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
3 ; NOTE: The checks for opt are NOT added by the update script. Those
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
4 ; checks are looking for the absence of specific metadata, which
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
5 ; cannot be expressed reliably by the generated checks.
150
anatofuz
parents:
diff changeset
6
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
7 ; RUN: llc -march=amdgcn -mcpu=gfx900 -verify-machineinstrs < %s | FileCheck %s -check-prefix=ISA
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
8 ; RUN: opt --amdgpu-annotate-uniform -S %s | FileCheck %s -check-prefix=UNIFORM
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
9 ; RUN: opt --amdgpu-annotate-uniform --si-annotate-control-flow -S %s | FileCheck %s -check-prefix=CONTROLFLOW
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
10
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
11 ; This module creates a divergent branch in block Flow2. The branch is
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
12 ; marked as divergent by the divergence analysis but the condition is
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
13 ; not. This test ensures that the divergence of the branch is tested,
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
14 ; not its condition, so that branch is correctly emitted as divergent.
150
anatofuz
parents:
diff changeset
15
anatofuz
parents:
diff changeset
16 target triple = "amdgcn-mesa-mesa3d"
anatofuz
parents:
diff changeset
17
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
18 define amdgpu_ps void @main(i32 %0, float %1) {
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
19 ; ISA-LABEL: main:
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
20 ; ISA: ; %bb.0: ; %start
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
21 ; ISA-NEXT: v_readfirstlane_b32 s0, v0
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
22 ; ISA-NEXT: s_mov_b32 m0, s0
236
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
23 ; ISA-NEXT: s_mov_b32 s8, 0
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
24 ; ISA-NEXT: v_interp_p1_f32_e32 v0, v1, attr0.x
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
25 ; ISA-NEXT: v_cmp_nlt_f32_e32 vcc, 0, v0
236
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
26 ; ISA-NEXT: s_mov_b64 s[0:1], 0
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
27 ; ISA-NEXT: ; implicit-def: $sgpr4_sgpr5
236
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
28 ; ISA-NEXT: ; implicit-def: $sgpr2_sgpr3
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
29 ; ISA-NEXT: s_branch .LBB0_3
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
30 ; ISA-NEXT: .LBB0_1: ; %Flow1
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
31 ; ISA-NEXT: ; in Loop: Header=BB0_3 Depth=1
236
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
32 ; ISA-NEXT: s_or_b64 exec, exec, s[6:7]
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
33 ; ISA-NEXT: s_mov_b64 s[6:7], 0
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
34 ; ISA-NEXT: .LBB0_2: ; %Flow
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
35 ; ISA-NEXT: ; in Loop: Header=BB0_3 Depth=1
236
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
36 ; ISA-NEXT: s_and_b64 s[10:11], exec, s[4:5]
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
37 ; ISA-NEXT: s_or_b64 s[0:1], s[10:11], s[0:1]
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
38 ; ISA-NEXT: s_andn2_b64 s[2:3], s[2:3], exec
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
39 ; ISA-NEXT: s_and_b64 s[6:7], s[6:7], exec
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
40 ; ISA-NEXT: s_or_b64 s[2:3], s[2:3], s[6:7]
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
41 ; ISA-NEXT: s_andn2_b64 exec, exec, s[0:1]
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
42 ; ISA-NEXT: s_cbranch_execz .LBB0_6
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
43 ; ISA-NEXT: .LBB0_3: ; %loop
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
44 ; ISA-NEXT: ; =>This Inner Loop Header: Depth=1
236
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
45 ; ISA-NEXT: s_or_b64 s[4:5], s[4:5], exec
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
46 ; ISA-NEXT: s_cmp_lt_u32 s8, 32
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
47 ; ISA-NEXT: s_mov_b64 s[6:7], -1
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
48 ; ISA-NEXT: s_cbranch_scc0 .LBB0_2
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
49 ; ISA-NEXT: ; %bb.4: ; %endif1
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
50 ; ISA-NEXT: ; in Loop: Header=BB0_3 Depth=1
236
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
51 ; ISA-NEXT: s_mov_b64 s[4:5], -1
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
52 ; ISA-NEXT: s_and_saveexec_b64 s[6:7], vcc
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
53 ; ISA-NEXT: s_cbranch_execz .LBB0_1
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
54 ; ISA-NEXT: ; %bb.5: ; %endif2
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
55 ; ISA-NEXT: ; in Loop: Header=BB0_3 Depth=1
236
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
56 ; ISA-NEXT: s_add_i32 s8, s8, 1
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
57 ; ISA-NEXT: s_xor_b64 s[4:5], exec, -1
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
58 ; ISA-NEXT: s_branch .LBB0_1
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
59 ; ISA-NEXT: .LBB0_6: ; %Flow2
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
60 ; ISA-NEXT: s_or_b64 exec, exec, s[0:1]
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
61 ; ISA-NEXT: v_mov_b32_e32 v1, 0
236
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
62 ; ISA-NEXT: s_and_saveexec_b64 s[0:1], s[2:3]
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
63 ; ISA-NEXT: ; %bb.7: ; %if1
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
64 ; ISA-NEXT: v_sqrt_f32_e32 v1, v0
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
65 ; ISA-NEXT: ; %bb.8: ; %endloop
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
66 ; ISA-NEXT: s_or_b64 exec, exec, s[0:1]
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
67 ; ISA-NEXT: exp mrt0 v1, v1, v1, v1 done vm
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
68 ; ISA-NEXT: s_endpgm
150
anatofuz
parents:
diff changeset
69 start:
anatofuz
parents:
diff changeset
70 %v0 = call float @llvm.amdgcn.interp.p1(float %1, i32 0, i32 0, i32 %0)
anatofuz
parents:
diff changeset
71 br label %loop
anatofuz
parents:
diff changeset
72
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
73 loop: ; preds = %Flow, %start
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
74 %v1 = phi i32 [ 0, %start ], [ %6, %Flow ]
150
anatofuz
parents:
diff changeset
75 %v2 = icmp ugt i32 %v1, 31
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
76 %2 = xor i1 %v2, true
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
77 br i1 %2, label %endif1, label %Flow
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
78
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
79 Flow1: ; preds = %endif2, %endif1
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
80 %3 = phi i32 [ %v5, %endif2 ], [ undef, %endif1 ]
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
81 %4 = phi i1 [ false, %endif2 ], [ true, %endif1 ]
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
82 br label %Flow
150
anatofuz
parents:
diff changeset
83
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
84 ; UNIFORM-LABEL: Flow2:
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
85 ; UNIFORM-NEXT: br i1 %8, label %if1, label %endloop
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
86 ; UNIFORM-NOT: !amdgpu.uniform
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
87 ; UNIFORM: if1:
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
88
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
89 ; CONTROLFLOW-LABEL: Flow2:
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
90 ; CONTROLFLOW-NEXT: call void @llvm.amdgcn.end.cf.i64(i64 %{{.*}})
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
91 ; CONTROLFLOW-NEXT: [[IF:%.*]] = call { i1, i64 } @llvm.amdgcn.if.i64(i1 %{{.*}})
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
92 ; CONTROLFLOW-NEXT: [[COND:%.*]] = extractvalue { i1, i64 } [[IF]], 0
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
93 ; CONTROLFLOW-NEXT: %{{.*}} = extractvalue { i1, i64 } [[IF]], 1
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
94 ; CONTROLFLOW-NEXT: br i1 [[COND]], label %if1, label %endloop
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
95
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
96 Flow2: ; preds = %Flow
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
97 br i1 %8, label %if1, label %endloop
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
98
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
99 if1: ; preds = %Flow2
150
anatofuz
parents:
diff changeset
100 %v3 = call float @llvm.sqrt.f32(float %v0)
anatofuz
parents:
diff changeset
101 br label %endloop
anatofuz
parents:
diff changeset
102
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
103 endif1: ; preds = %loop
150
anatofuz
parents:
diff changeset
104 %v4 = fcmp ogt float %v0, 0.000000e+00
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
105 %5 = xor i1 %v4, true
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
106 br i1 %5, label %endif2, label %Flow1
150
anatofuz
parents:
diff changeset
107
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
108 Flow: ; preds = %Flow1, %loop
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
109 %6 = phi i32 [ %3, %Flow1 ], [ undef, %loop ]
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
110 %7 = phi i1 [ %4, %Flow1 ], [ true, %loop ]
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
111 %8 = phi i1 [ false, %Flow1 ], [ true, %loop ]
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
112 br i1 %7, label %Flow2, label %loop
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
113
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
114 endif2: ; preds = %endif1
150
anatofuz
parents:
diff changeset
115 %v5 = add i32 %v1, 1
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
116 br label %Flow1
150
anatofuz
parents:
diff changeset
117
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
118 endloop: ; preds = %if1, %Flow2
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
119 %v6 = phi float [ 0.000000e+00, %Flow2 ], [ %v3, %if1 ]
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
120 call void @llvm.amdgcn.exp.f32(i32 0, i32 15, float %v6, float %v6, float %v6, float %v6, i1 true, i1 true)
150
anatofuz
parents:
diff changeset
121 ret void
anatofuz
parents:
diff changeset
122 }
anatofuz
parents:
diff changeset
123
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
124 ; Function Attrs: nounwind readnone speculatable willreturn
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
125 declare float @llvm.sqrt.f32(float) #0
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
126
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
127 ; Function Attrs: nounwind readnone speculatable
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
128 declare float @llvm.amdgcn.interp.p1(float, i32 immarg, i32 immarg, i32) #1
150
anatofuz
parents:
diff changeset
129
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
130 ; Function Attrs: inaccessiblememonly nounwind writeonly
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
131 declare void @llvm.amdgcn.exp.f32(i32 immarg, i32 immarg, float, float, float, float, i1 immarg, i1 immarg) #2
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
132
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
133 attributes #0 = { nounwind readnone speculatable willreturn }
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
134 attributes #1 = { nounwind readnone speculatable }
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
135 attributes #2 = { inaccessiblememonly nounwind writeonly }