1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -mtriple=amdgcn-- -S -o - -structurizecfg -structurizecfg-skip-uniform-regions -structurizecfg-relaxed-uniform-regions < %s | FileCheck %s
4 define amdgpu_cs void @uniform(i32 inreg %v) {
5 ; CHECK-LABEL: @uniform(
7 ; CHECK-NEXT: [[CC:%.*]] = icmp eq i32 [[V:%.*]], 0
8 ; CHECK-NEXT: br i1 [[CC]], label [[IF:%.*]], label [[END:%.*]], !structurizecfg.uniform !0
10 ; CHECK-NEXT: br label [[END]], !structurizecfg.uniform !0
12 ; CHECK-NEXT: ret void
15 %cc = icmp eq i32 %v, 0
16 br i1 %cc, label %if, label %end
25 define amdgpu_cs void @nonuniform(i32 addrspace(4)* %ptr) {
26 ; CHECK-LABEL: @nonuniform(
28 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
30 ; CHECK-NEXT: [[I:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[TMP0:%.*]], [[FLOW:%.*]] ]
31 ; CHECK-NEXT: [[CC:%.*]] = icmp ult i32 [[I]], 4
32 ; CHECK-NEXT: br i1 [[CC]], label [[MID_LOOP:%.*]], label [[FLOW]]
34 ; CHECK-NEXT: [[V:%.*]] = call i32 @llvm.amdgcn.workitem.id.x()
35 ; CHECK-NEXT: [[CC2:%.*]] = icmp eq i32 [[V]], 0
36 ; CHECK-NEXT: br i1 [[CC2]], label [[END_LOOP:%.*]], label [[FLOW1:%.*]]
38 ; CHECK-NEXT: [[TMP0]] = phi i32 [ [[TMP2:%.*]], [[FLOW1]] ], [ undef, [[FOR_BODY]] ]
39 ; CHECK-NEXT: [[TMP1:%.*]] = phi i1 [ [[TMP3:%.*]], [[FLOW1]] ], [ true, [[FOR_BODY]] ]
40 ; CHECK-NEXT: br i1 [[TMP1]], label [[FOR_END:%.*]], label [[FOR_BODY]]
42 ; CHECK-NEXT: [[I_INC:%.*]] = add i32 [[I]], 1
43 ; CHECK-NEXT: br label [[FLOW1]]
45 ; CHECK-NEXT: [[TMP2]] = phi i32 [ [[I_INC]], [[END_LOOP]] ], [ undef, [[MID_LOOP]] ]
46 ; CHECK-NEXT: [[TMP3]] = phi i1 [ false, [[END_LOOP]] ], [ true, [[MID_LOOP]] ]
47 ; CHECK-NEXT: br label [[FLOW]]
49 ; CHECK-NEXT: br i1 [[CC]], label [[IF:%.*]], label [[END:%.*]]
51 ; CHECK-NEXT: br label [[END]]
53 ; CHECK-NEXT: ret void
59 %i = phi i32 [0, %entry], [%i.inc, %end.loop]
60 %cc = icmp ult i32 %i, 4
61 br i1 %cc, label %mid.loop, label %for.end
64 %v = call i32 @llvm.amdgcn.workitem.id.x()
65 %cc2 = icmp eq i32 %v, 0
66 br i1 %cc2, label %end.loop, label %for.end
69 %i.inc = add i32 %i, 1
73 br i1 %cc, label %if, label %end
82 define amdgpu_cs void @uniform_branch_to_nonuniform_subregions(i32 addrspace(4)* %ptr, i32 inreg %data) {
83 ; CHECK-LABEL: @uniform_branch_to_nonuniform_subregions(
85 ; CHECK-NEXT: [[C:%.*]] = icmp eq i32 [[DATA:%.*]], 42
86 ; CHECK-NEXT: br i1 [[C]], label [[UNIFORM_FOR_BODY:%.*]], label [[FOR_BODY:%.*]], !structurizecfg.uniform !0
88 ; CHECK-NEXT: [[I:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[TMP0:%.*]], [[FLOW1:%.*]] ]
89 ; CHECK-NEXT: [[CC:%.*]] = icmp ult i32 [[I]], 4
90 ; CHECK-NEXT: br i1 [[CC]], label [[MID_LOOP:%.*]], label [[FLOW1]]
92 ; CHECK-NEXT: [[V:%.*]] = call i32 @llvm.amdgcn.workitem.id.x()
93 ; CHECK-NEXT: [[CC2:%.*]] = icmp eq i32 [[V]], 0
94 ; CHECK-NEXT: br i1 [[CC2]], label [[END_LOOP:%.*]], label [[FLOW2:%.*]]
96 ; CHECK-NEXT: [[TMP0]] = phi i32 [ [[TMP2:%.*]], [[FLOW2]] ], [ undef, [[FOR_BODY]] ]
97 ; CHECK-NEXT: [[TMP1:%.*]] = phi i1 [ [[TMP3:%.*]], [[FLOW2]] ], [ true, [[FOR_BODY]] ]
98 ; CHECK-NEXT: br i1 [[TMP1]], label [[FOR_END:%.*]], label [[FOR_BODY]]
100 ; CHECK-NEXT: [[I_INC:%.*]] = add i32 [[I]], 1
101 ; CHECK-NEXT: br label [[FLOW2]]
103 ; CHECK-NEXT: [[TMP2]] = phi i32 [ [[I_INC]], [[END_LOOP]] ], [ undef, [[MID_LOOP]] ]
104 ; CHECK-NEXT: [[TMP3]] = phi i1 [ false, [[END_LOOP]] ], [ true, [[MID_LOOP]] ]
105 ; CHECK-NEXT: br label [[FLOW1]]
107 ; CHECK-NEXT: br i1 [[CC]], label [[IF:%.*]], label [[FLOW:%.*]]
109 ; CHECK-NEXT: br label [[FLOW]]
110 ; CHECK: uniform.for.body:
111 ; CHECK-NEXT: [[UNIFORM_I:%.*]] = phi i32 [ 0, [[ENTRY]] ], [ [[TMP4:%.*]], [[FLOW4:%.*]] ]
112 ; CHECK-NEXT: [[UNIFORM_CC:%.*]] = icmp ult i32 [[UNIFORM_I]], 4
113 ; CHECK-NEXT: br i1 [[UNIFORM_CC]], label [[UNIFORM_MID_LOOP:%.*]], label [[FLOW4]]
114 ; CHECK: uniform.mid.loop:
115 ; CHECK-NEXT: [[UNIFORM_V:%.*]] = call i32 @llvm.amdgcn.workitem.id.x()
116 ; CHECK-NEXT: [[UNIFORM_CC2:%.*]] = icmp eq i32 [[UNIFORM_V]], 0
117 ; CHECK-NEXT: br i1 [[UNIFORM_CC2]], label [[UNIFORM_END_LOOP:%.*]], label [[FLOW5:%.*]]
119 ; CHECK-NEXT: [[TMP4]] = phi i32 [ [[TMP6:%.*]], [[FLOW5]] ], [ undef, [[UNIFORM_FOR_BODY]] ]
120 ; CHECK-NEXT: [[TMP5:%.*]] = phi i1 [ [[TMP7:%.*]], [[FLOW5]] ], [ true, [[UNIFORM_FOR_BODY]] ]
121 ; CHECK-NEXT: br i1 [[TMP5]], label [[UNIFORM_FOR_END:%.*]], label [[UNIFORM_FOR_BODY]]
122 ; CHECK: uniform.end.loop:
123 ; CHECK-NEXT: [[UNIFORM_I_INC:%.*]] = add i32 [[UNIFORM_I]], 1
124 ; CHECK-NEXT: br label [[FLOW5]]
126 ; CHECK-NEXT: [[TMP6]] = phi i32 [ [[UNIFORM_I_INC]], [[UNIFORM_END_LOOP]] ], [ undef, [[UNIFORM_MID_LOOP]] ]
127 ; CHECK-NEXT: [[TMP7]] = phi i1 [ false, [[UNIFORM_END_LOOP]] ], [ true, [[UNIFORM_MID_LOOP]] ]
128 ; CHECK-NEXT: br label [[FLOW4]]
129 ; CHECK: uniform.for.end:
130 ; CHECK-NEXT: br i1 [[UNIFORM_CC]], label [[UNIFORM_IF:%.*]], label [[FLOW3:%.*]]
132 ; CHECK-NEXT: br label [[FLOW3]]
134 ; CHECK-NEXT: br label [[END:%.*]]
136 ; CHECK-NEXT: br label [[END]]
138 ; CHECK-NEXT: ret void
141 %c = icmp eq i32 %data, 42
142 br i1 %c, label %uniform.for.body, label %for.body
145 %i = phi i32 [0, %entry], [%i.inc, %end.loop]
146 %cc = icmp ult i32 %i, 4
147 br i1 %cc, label %mid.loop, label %for.end
150 %v = call i32 @llvm.amdgcn.workitem.id.x()
151 %cc2 = icmp eq i32 %v, 0
152 br i1 %cc2, label %end.loop, label %for.end
155 %i.inc = add i32 %i, 1
159 br i1 %cc, label %if, label %end
165 %uniform.i = phi i32 [0, %entry], [%uniform.i.inc, %uniform.end.loop]
166 %uniform.cc = icmp ult i32 %uniform.i, 4
167 br i1 %uniform.cc, label %uniform.mid.loop, label %uniform.for.end
170 %uniform.v = call i32 @llvm.amdgcn.workitem.id.x()
171 %uniform.cc2 = icmp eq i32 %uniform.v, 0
172 br i1 %uniform.cc2, label %uniform.end.loop, label %uniform.for.end
175 %uniform.i.inc = add i32 %uniform.i, 1
176 br label %uniform.for.body
179 br i1 %uniform.cc, label %uniform.if, label %end
188 declare i32 @llvm.amdgcn.workitem.id.x()