1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -S -passes=simplifycfg -simplifycfg-require-and-preserve-domtree=1 | FileCheck %s
4 declare void @sideeffect0()
5 declare void @sideeffect1()
6 declare void @sideeffect2()
10 define i1 @t0_or_binop(i8 %v0, i8 %v1, i8 %v2, i1 %v3) {
11 ; CHECK-LABEL: @t0_or_binop(
13 ; CHECK-NEXT: [[C0:%.*]] = icmp eq i8 [[V0:%.*]], 0
14 ; CHECK-NEXT: br i1 [[C0]], label [[PRED0:%.*]], label [[END:%.*]]
16 ; CHECK-NEXT: [[C1:%.*]] = icmp eq i8 [[V1:%.*]], 0
17 ; CHECK-NEXT: [[C2:%.*]] = icmp eq i8 [[V2:%.*]], 0
18 ; CHECK-NEXT: [[COMPUTED:%.*]] = or i1 [[C1]], [[C2]]
19 ; CHECK-NEXT: br label [[END]]
21 ; CHECK-NEXT: [[R:%.*]] = phi i1 [ [[COMPUTED]], [[PRED0]] ], [ [[V3:%.*]], [[ENTRY:%.*]] ]
22 ; CHECK-NEXT: ret i1 [[R]]
25 %c0 = icmp eq i8 %v0, 0 ; canonical predicate
26 br i1 %c0, label %pred0, label %pred1
29 %c1 = icmp eq i8 %v1, 0 ; canonical predicate
30 %c2 = icmp eq i8 %v2, 0 ; canonical predicate
31 %computed = or i1 %c1, %c2 ; binary or
38 %r = phi i1 [ %computed, %pred0 ], [ %v3, %pred1 ]
41 define i1 @t1_or_logical(i8 %v0, i8 %v1, i8 %v2, i1 %v3) {
42 ; CHECK-LABEL: @t1_or_logical(
44 ; CHECK-NEXT: [[C0:%.*]] = icmp eq i8 [[V0:%.*]], 0
45 ; CHECK-NEXT: br i1 [[C0]], label [[PRED0:%.*]], label [[END:%.*]]
47 ; CHECK-NEXT: [[C1:%.*]] = icmp eq i8 [[V1:%.*]], 0
48 ; CHECK-NEXT: [[C2:%.*]] = icmp eq i8 [[V2:%.*]], 0
49 ; CHECK-NEXT: [[COMPUTED:%.*]] = select i1 [[C1]], i1 true, i1 [[C2]]
50 ; CHECK-NEXT: br label [[END]]
52 ; CHECK-NEXT: [[R:%.*]] = phi i1 [ [[COMPUTED]], [[PRED0]] ], [ [[V3:%.*]], [[ENTRY:%.*]] ]
53 ; CHECK-NEXT: ret i1 [[R]]
56 %c0 = icmp eq i8 %v0, 0 ; canonical predicate
57 br i1 %c0, label %pred0, label %pred1
60 %c1 = icmp eq i8 %v1, 0 ; canonical predicate
61 %c2 = icmp eq i8 %v2, 0 ; canonical predicate
62 %computed = select i1 %c1, i1 true, i1 %c2 ; logical or
69 %r = phi i1 [ %computed, %pred0 ], [ %v3, %pred1 ]
73 define i1 @t2_and_binop(i8 %v0, i8 %v1, i8 %v2, i1 %v3) {
74 ; CHECK-LABEL: @t2_and_binop(
76 ; CHECK-NEXT: [[C0:%.*]] = icmp eq i8 [[V0:%.*]], 0
77 ; CHECK-NEXT: br i1 [[C0]], label [[PRED0:%.*]], label [[END:%.*]]
79 ; CHECK-NEXT: [[C1:%.*]] = icmp eq i8 [[V1:%.*]], 0
80 ; CHECK-NEXT: [[C2:%.*]] = icmp eq i8 [[V2:%.*]], 0
81 ; CHECK-NEXT: [[COMPUTED:%.*]] = and i1 [[C1]], [[C2]]
82 ; CHECK-NEXT: br label [[END]]
84 ; CHECK-NEXT: [[R:%.*]] = phi i1 [ [[COMPUTED]], [[PRED0]] ], [ [[V3:%.*]], [[ENTRY:%.*]] ]
85 ; CHECK-NEXT: ret i1 [[R]]
88 %c0 = icmp eq i8 %v0, 0 ; canonical predicate
89 br i1 %c0, label %pred0, label %pred1
92 %c1 = icmp eq i8 %v1, 0 ; canonical predicate
93 %c2 = icmp eq i8 %v2, 0 ; canonical predicate
94 %computed = and i1 %c1, %c2 ; binary and
101 %r = phi i1 [ %computed, %pred0 ], [ %v3, %pred1 ]
104 define i1 @t3_and_logical(i8 %v0, i8 %v1, i8 %v2, i1 %v3) {
105 ; CHECK-LABEL: @t3_and_logical(
107 ; CHECK-NEXT: [[C0:%.*]] = icmp eq i8 [[V0:%.*]], 0
108 ; CHECK-NEXT: br i1 [[C0]], label [[PRED0:%.*]], label [[END:%.*]]
110 ; CHECK-NEXT: [[C1:%.*]] = icmp eq i8 [[V1:%.*]], 0
111 ; CHECK-NEXT: [[C2:%.*]] = icmp eq i8 [[V2:%.*]], 0
112 ; CHECK-NEXT: [[COMPUTED:%.*]] = select i1 [[C1]], i1 [[C2]], i1 false
113 ; CHECK-NEXT: br label [[END]]
115 ; CHECK-NEXT: [[R:%.*]] = phi i1 [ [[COMPUTED]], [[PRED0]] ], [ [[V3:%.*]], [[ENTRY:%.*]] ]
116 ; CHECK-NEXT: ret i1 [[R]]
119 %c0 = icmp eq i8 %v0, 0 ; canonical predicate
120 br i1 %c0, label %pred0, label %pred1
123 %c1 = icmp eq i8 %v1, 0 ; canonical predicate
124 %c2 = icmp eq i8 %v2, 0 ; canonical predicate
125 %computed = select i1 %c1, i1 %c2, i1 false ; logical and
132 %r = phi i1 [ %computed, %pred0 ], [ %v3, %pred1 ]
137 define i1 @t4_nor_binop(i8 %v0, i8 %v1, i8 %v2, i1 %v3) {
138 ; CHECK-LABEL: @t4_nor_binop(
140 ; CHECK-NEXT: [[C0:%.*]] = icmp eq i8 [[V0:%.*]], 0
141 ; CHECK-NEXT: br i1 [[C0]], label [[PRED0:%.*]], label [[END:%.*]]
143 ; CHECK-NEXT: [[C1:%.*]] = icmp ne i8 [[V1:%.*]], 0
144 ; CHECK-NEXT: [[C2:%.*]] = icmp ne i8 [[V2:%.*]], 0
145 ; CHECK-NEXT: [[COMPUTED:%.*]] = and i1 [[C1]], [[C2]]
146 ; CHECK-NEXT: br label [[END]]
148 ; CHECK-NEXT: [[R:%.*]] = phi i1 [ [[COMPUTED]], [[PRED0]] ], [ [[V3:%.*]], [[ENTRY:%.*]] ]
149 ; CHECK-NEXT: ret i1 [[R]]
152 %c0 = icmp eq i8 %v0, 0 ; canonical predicate
153 br i1 %c0, label %pred0, label %pred1
156 %c1 = icmp ne i8 %v1, 0 ; non-canonical predicate
157 %c2 = icmp ne i8 %v2, 0 ; non-canonical predicate
158 %computed = and i1 %c1, %c2 ; binary and
165 %r = phi i1 [ %computed, %pred0 ], [ %v3, %pred1 ]
168 define i1 @t5_nor_logical(i8 %v0, i8 %v1, i8 %v2, i1 %v3) {
169 ; CHECK-LABEL: @t5_nor_logical(
171 ; CHECK-NEXT: [[C0:%.*]] = icmp eq i8 [[V0:%.*]], 0
172 ; CHECK-NEXT: br i1 [[C0]], label [[PRED0:%.*]], label [[END:%.*]]
174 ; CHECK-NEXT: [[C1:%.*]] = icmp ne i8 [[V1:%.*]], 0
175 ; CHECK-NEXT: [[C2:%.*]] = icmp ne i8 [[V2:%.*]], 0
176 ; CHECK-NEXT: [[COMPUTED:%.*]] = select i1 [[C1]], i1 [[C2]], i1 false
177 ; CHECK-NEXT: br label [[END]]
179 ; CHECK-NEXT: [[R:%.*]] = phi i1 [ [[COMPUTED]], [[PRED0]] ], [ [[V3:%.*]], [[ENTRY:%.*]] ]
180 ; CHECK-NEXT: ret i1 [[R]]
183 %c0 = icmp eq i8 %v0, 0 ; canonical predicate
184 br i1 %c0, label %pred0, label %pred1
187 %c1 = icmp ne i8 %v1, 0 ; non-canonical predicate
188 %c2 = icmp ne i8 %v2, 0 ; non-canonical predicate
189 %computed = select i1 %c1, i1 %c2, i1 false ; logical and
196 %r = phi i1 [ %computed, %pred0 ], [ %v3, %pred1 ]
199 define i1 @t6_nor_logical2(i8 %v0, i8 %v1, i8 %v2, i1 %v3) {
200 ; CHECK-LABEL: @t6_nor_logical2(
202 ; CHECK-NEXT: [[C0:%.*]] = icmp eq i8 [[V0:%.*]], 0
203 ; CHECK-NEXT: br i1 [[C0]], label [[PRED0:%.*]], label [[END:%.*]]
205 ; CHECK-NEXT: [[C1:%.*]] = icmp eq i8 [[V1:%.*]], 0
206 ; CHECK-NEXT: [[C2:%.*]] = icmp ne i8 [[V2:%.*]], 0
207 ; CHECK-NEXT: [[COMPUTED:%.*]] = select i1 [[C1]], i1 false, i1 [[C2]]
208 ; CHECK-NEXT: br label [[END]]
210 ; CHECK-NEXT: [[R:%.*]] = phi i1 [ [[COMPUTED]], [[PRED0]] ], [ [[V3:%.*]], [[ENTRY:%.*]] ]
211 ; CHECK-NEXT: ret i1 [[R]]
214 %c0 = icmp eq i8 %v0, 0
215 br i1 %c0, label %pred0, label %pred1
218 %c1 = icmp eq i8 %v1, 0 ; canonical predicate
219 %c2 = icmp ne i8 %v2, 0 ; non-canonical predicate
220 %computed = select i1 %c1, i1 false, i1 %c2 ; huh, what is this, logical nand?
227 %r = phi i1 [ %computed, %pred0 ], [ %v3, %pred1 ]
231 define i1 @t7_nand_binop(i8 %v0, i8 %v1, i8 %v2, i1 %v3) {
232 ; CHECK-LABEL: @t7_nand_binop(
234 ; CHECK-NEXT: [[C0:%.*]] = icmp eq i8 [[V0:%.*]], 0
235 ; CHECK-NEXT: br i1 [[C0]], label [[PRED0:%.*]], label [[END:%.*]]
237 ; CHECK-NEXT: [[C1:%.*]] = icmp ne i8 [[V1:%.*]], 0
238 ; CHECK-NEXT: [[C2:%.*]] = icmp ne i8 [[V2:%.*]], 0
239 ; CHECK-NEXT: [[COMPUTED:%.*]] = or i1 [[C1]], [[C2]]
240 ; CHECK-NEXT: br label [[END]]
242 ; CHECK-NEXT: [[R:%.*]] = phi i1 [ [[COMPUTED]], [[PRED0]] ], [ [[V3:%.*]], [[ENTRY:%.*]] ]
243 ; CHECK-NEXT: ret i1 [[R]]
246 %c0 = icmp eq i8 %v0, 0 ; canonical predicate
247 br i1 %c0, label %pred0, label %pred1
250 %c1 = icmp ne i8 %v1, 0 ; non-canonical predicate
251 %c2 = icmp ne i8 %v2, 0 ; non-canonical predicate
252 %computed = or i1 %c1, %c2 ; binary and
259 %r = phi i1 [ %computed, %pred0 ], [ %v3, %pred1 ]
262 define i1 @t8_nand_logical(i8 %v0, i8 %v1, i8 %v2, i1 %v3) {
263 ; CHECK-LABEL: @t8_nand_logical(
265 ; CHECK-NEXT: [[C0:%.*]] = icmp eq i8 [[V0:%.*]], 0
266 ; CHECK-NEXT: br i1 [[C0]], label [[PRED0:%.*]], label [[END:%.*]]
268 ; CHECK-NEXT: [[C1:%.*]] = icmp ne i8 [[V1:%.*]], 0
269 ; CHECK-NEXT: [[C2:%.*]] = icmp ne i8 [[V2:%.*]], 0
270 ; CHECK-NEXT: [[COMPUTED:%.*]] = select i1 [[C1]], i1 true, i1 [[C2]]
271 ; CHECK-NEXT: br label [[END]]
273 ; CHECK-NEXT: [[R:%.*]] = phi i1 [ [[COMPUTED]], [[PRED0]] ], [ [[V3:%.*]], [[ENTRY:%.*]] ]
274 ; CHECK-NEXT: ret i1 [[R]]
277 %c0 = icmp eq i8 %v0, 0 ; canonical predicate
278 br i1 %c0, label %pred0, label %pred1
281 %c1 = icmp ne i8 %v1, 0 ; non-canonical predicate
282 %c2 = icmp ne i8 %v2, 0 ; non-canonical predicate
283 %computed = select i1 %c1, i1 true, i1 %c2 ; logical or
290 %r = phi i1 [ %computed, %pred0 ], [ %v3, %pred1 ]
293 define i1 @t9_nand_logical2(i8 %v0, i8 %v1, i8 %v2, i1 %v3) {
294 ; CHECK-LABEL: @t9_nand_logical2(
296 ; CHECK-NEXT: [[C0:%.*]] = icmp eq i8 [[V0:%.*]], 0
297 ; CHECK-NEXT: br i1 [[C0]], label [[PRED0:%.*]], label [[END:%.*]]
299 ; CHECK-NEXT: [[C1:%.*]] = icmp eq i8 [[V1:%.*]], 0
300 ; CHECK-NEXT: [[C2:%.*]] = icmp ne i8 [[V2:%.*]], 0
301 ; CHECK-NEXT: [[COMPUTED:%.*]] = select i1 [[C1]], i1 [[C2]], i1 true
302 ; CHECK-NEXT: br label [[END]]
304 ; CHECK-NEXT: [[R:%.*]] = phi i1 [ [[COMPUTED]], [[PRED0]] ], [ [[V3:%.*]], [[ENTRY:%.*]] ]
305 ; CHECK-NEXT: ret i1 [[R]]
308 %c0 = icmp eq i8 %v0, 0 ; canonical predicate
309 br i1 %c0, label %pred0, label %pred1
312 %c1 = icmp eq i8 %v1, 0 ; canonical predicate
313 %c2 = icmp ne i8 %v2, 0 ; non-canonical predicate
314 %computed = select i1 %c1, i1 %c2, i1 true ; huh, what is this, logical nor?
321 %r = phi i1 [ %computed, %pred0 ], [ %v3, %pred1 ]