1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=instsimplify -S | FileCheck %s
4 define i64 @test0(i64 %x) {
7 ; CHECK-NEXT: [[A:%.*]] = icmp eq i64 [[X:%.*]], 0
8 ; CHECK-NEXT: br i1 [[A]], label [[EXIT:%.*]], label [[NON_ZERO:%.*]]
10 ; CHECK-NEXT: br i1 false, label [[UNREACHABLE:%.*]], label [[EXIT]]
12 ; CHECK-NEXT: br label [[EXIT]]
14 ; CHECK-NEXT: [[C:%.*]] = phi i64 [ 0, [[START:%.*]] ], [ 1, [[NON_ZERO]] ], [ 2, [[UNREACHABLE]] ]
15 ; CHECK-NEXT: ret i64 [[C]]
18 %a = icmp eq i64 %x, 0
19 br i1 %a, label %exit, label %non_zero
22 %b = icmp eq i64 %x, 0
23 br i1 %b, label %unreachable, label %exit
29 %c = phi i64 [ 0, %start ], [ 1, %non_zero ], [ 2, %unreachable ]
33 define i64 @test1(i64 %x) {
34 ; CHECK-LABEL: @test1(
36 ; CHECK-NEXT: [[A:%.*]] = icmp eq i64 [[X:%.*]], 0
37 ; CHECK-NEXT: br i1 [[A]], label [[EXIT:%.*]], label [[NON_ZERO:%.*]]
39 ; CHECK-NEXT: br i1 true, label [[EXIT]], label [[UNREACHABLE:%.*]]
41 ; CHECK-NEXT: br label [[EXIT]]
43 ; CHECK-NEXT: [[C:%.*]] = phi i64 [ 0, [[START:%.*]] ], [ [[X]], [[NON_ZERO]] ], [ 0, [[UNREACHABLE]] ]
44 ; CHECK-NEXT: ret i64 [[C]]
47 %a = icmp eq i64 %x, 0
48 br i1 %a, label %exit, label %non_zero
51 %b = icmp ugt i64 %x, 0
52 br i1 %b, label %exit, label %unreachable
58 %c = phi i64 [ 0, %start ], [ %x, %non_zero ], [ 0, %unreachable ]
62 define i1 @test2(i64 %x, i1 %y) {
63 ; CHECK-LABEL: @test2(
65 ; CHECK-NEXT: [[A:%.*]] = icmp eq i64 [[X:%.*]], 0
66 ; CHECK-NEXT: br i1 [[A]], label [[EXIT:%.*]], label [[NON_ZERO:%.*]]
68 ; CHECK-NEXT: br i1 [[Y:%.*]], label [[ONE:%.*]], label [[TWO:%.*]]
70 ; CHECK-NEXT: br label [[MAINBLOCK:%.*]]
72 ; CHECK-NEXT: br label [[MAINBLOCK]]
74 ; CHECK-NEXT: br label [[EXIT]]
76 ; CHECK-NEXT: [[RES:%.*]] = phi i1 [ false, [[MAINBLOCK]] ], [ true, [[START:%.*]] ]
77 ; CHECK-NEXT: ret i1 [[RES]]
80 %a = icmp eq i64 %x, 0
81 br i1 %a, label %exit, label %non_zero
84 br i1 %y, label %one, label %two
93 %p = phi i64 [ %x, %one ], [ 42, %two ]
94 %cmp = icmp eq i64 %p, 0
98 %res = phi i1 [ %cmp, %mainblock ], [ 1, %start ]
103 ; The code below exposed a bug similar to the one exposed by D60846, see the commit 6ea477590085.
104 ; In a nutshell, we should not replace %result.0 with 0 here.
106 define zeroext i8 @update_phi_query_loc_in_recursive_call(ptr nocapture readonly %p){
107 ; CHECK-LABEL: @update_phi_query_loc_in_recursive_call(
109 ; CHECK-NEXT: br label [[FOR_COND:%.*]]
111 ; CHECK-NEXT: [[RESULT_0:%.*]] = phi i8 [ 0, [[ENTRY:%.*]] ], [ [[CONV2:%.*]], [[FOR_BODY:%.*]] ]
112 ; CHECK-NEXT: [[SHIFT_0:%.*]] = phi i32 [ 0, [[ENTRY]] ], [ 1, [[FOR_BODY]] ]
113 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[SHIFT_0]], 0
114 ; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_COND_CLEANUP:%.*]]
115 ; CHECK: for.cond.cleanup:
116 ; CHECK-NEXT: ret i8 [[RESULT_0]]
118 ; CHECK-NEXT: [[TMP0:%.*]] = load i8, ptr [[P:%.*]], align 1
119 ; CHECK-NEXT: [[CONV:%.*]] = zext i8 [[TMP0]] to i32
120 ; CHECK-NEXT: [[MUL:%.*]] = shl nuw nsw i32 [[SHIFT_0]], 3
121 ; CHECK-NEXT: [[SHL:%.*]] = shl nuw nsw i32 [[CONV]], [[MUL]]
122 ; CHECK-NEXT: [[TMP1:%.*]] = trunc i32 [[SHL]] to i8
123 ; CHECK-NEXT: [[CONV2]] = or i8 [[RESULT_0]], [[TMP1]]
124 ; CHECK-NEXT: br label [[FOR_COND]]
129 for.cond: ; preds = %for.body, %entry
130 %result.0 = phi i8 [ 0, %entry ], [ %conv2, %for.body ]
131 %shift.0 = phi i32 [ 0, %entry ], [ 1, %for.body ]
132 %cmp = icmp eq i32 %shift.0, 0
133 br i1 %cmp, label %for.body, label %for.cond.cleanup
135 for.cond.cleanup: ; preds = %for.cond
138 for.body: ; preds = %for.cond
139 %0 = load i8, ptr %p, align 1
140 %conv = zext i8 %0 to i32
141 %mul = shl nuw nsw i32 %shift.0, 3
142 %shl = shl nuw nsw i32 %conv, %mul
143 %1 = trunc i32 %shl to i8
144 %conv2 = or i8 %result.0, %1
145 %inc = add nuw nsw i32 %shift.0, 1
149 define i1 @freeze_nonzero(i8 %x, i8 %mask) {
150 ; CHECK-LABEL: @freeze_nonzero(
151 ; CHECK-NEXT: [[Y:%.*]] = or i8 [[X:%.*]], [[MASK:%.*]]
152 ; CHECK-NEXT: [[C:%.*]] = icmp ne i8 [[Y]], 0
153 ; CHECK-NEXT: br i1 [[C]], label [[A:%.*]], label [[B:%.*]]
155 ; CHECK-NEXT: ret i1 false
157 ; CHECK-NEXT: ret i1 false
160 %c = icmp ne i8 %y, 0
161 br i1 %c, label %A, label %B
164 %c2 = icmp eq i8 %fr, 0
170 define i1 @smax_non_zero(i8 %xx, i8 %y) {
171 ; CHECK-LABEL: @smax_non_zero(
172 ; CHECK-NEXT: ret i1 false
176 %v = call i8 @llvm.smax.i8(i8 %x, i8 %y)
177 %r = icmp eq i8 %v, 0
181 define <4 x i1> @shuf_nonzero_both(<4 x i8> %xx, <4 x i8> %yy) {
182 ; CHECK-LABEL: @shuf_nonzero_both(
183 ; CHECK-NEXT: ret <4 x i1> zeroinitializer
185 %x = add nuw <4 x i8> %xx, <i8 1, i8 1, i8 1, i8 1>
186 %y = add nuw <4 x i8> %yy, <i8 1, i8 1, i8 1, i8 1>
188 %shuf = shufflevector <4 x i8> %x, <4 x i8> %y, <4 x i32> <i32 0, i32 4, i32 7, i32 2>
189 %r = icmp eq <4 x i8> %shuf, zeroinitializer
193 define <4 x i1> @shuf_nonzero_both_fail(<4 x i8> %xx, <4 x i8> %yy) {
194 ; CHECK-LABEL: @shuf_nonzero_both_fail(
195 ; CHECK-NEXT: [[X:%.*]] = add nuw <4 x i8> [[XX:%.*]], <i8 1, i8 1, i8 1, i8 1>
196 ; CHECK-NEXT: [[Y:%.*]] = add nuw <4 x i8> [[YY:%.*]], <i8 1, i8 1, i8 1, i8 0>
197 ; CHECK-NEXT: [[SHUF:%.*]] = shufflevector <4 x i8> [[X]], <4 x i8> [[Y]], <4 x i32> <i32 0, i32 4, i32 7, i32 2>
198 ; CHECK-NEXT: [[R:%.*]] = icmp eq <4 x i8> [[SHUF]], zeroinitializer
199 ; CHECK-NEXT: ret <4 x i1> [[R]]
201 %x = add nuw <4 x i8> %xx, <i8 1, i8 1, i8 1, i8 1>
202 %y = add nuw <4 x i8> %yy, <i8 1, i8 1, i8 1, i8 0>
204 %shuf = shufflevector <4 x i8> %x, <4 x i8> %y, <4 x i32> <i32 0, i32 4, i32 7, i32 2>
205 %r = icmp eq <4 x i8> %shuf, zeroinitializer
209 define <4 x i1> @shuf_nonzero_both_fail2(<4 x i8> %xx, <4 x i8> %yy) {
210 ; CHECK-LABEL: @shuf_nonzero_both_fail2(
211 ; CHECK-NEXT: [[X:%.*]] = add nuw <4 x i8> [[XX:%.*]], <i8 1, i8 1, i8 1, i8 1>
212 ; CHECK-NEXT: [[Y:%.*]] = add <4 x i8> [[YY:%.*]], <i8 1, i8 1, i8 1, i8 1>
213 ; CHECK-NEXT: [[SHUF:%.*]] = shufflevector <4 x i8> [[X]], <4 x i8> [[Y]], <4 x i32> <i32 0, i32 4, i32 7, i32 2>
214 ; CHECK-NEXT: [[R:%.*]] = icmp eq <4 x i8> [[SHUF]], zeroinitializer
215 ; CHECK-NEXT: ret <4 x i1> [[R]]
217 %x = add nuw <4 x i8> %xx, <i8 1, i8 1, i8 1, i8 1>
218 %y = add <4 x i8> %yy, <i8 1, i8 1, i8 1, i8 1>
220 %shuf = shufflevector <4 x i8> %x, <4 x i8> %y, <4 x i32> <i32 0, i32 4, i32 7, i32 2>
221 %r = icmp eq <4 x i8> %shuf, zeroinitializer
225 define <4 x i1> @shuf_nonzero_lhs(<4 x i8> %xx) {
226 ; CHECK-LABEL: @shuf_nonzero_lhs(
227 ; CHECK-NEXT: ret <4 x i1> zeroinitializer
229 %x = add nuw <4 x i8> %xx, <i8 1, i8 1, i8 1, i8 1>
231 %shuf = shufflevector <4 x i8> %x, <4 x i8> poison, <4 x i32> <i32 2, i32 2, i32 0, i32 1>
232 %r = icmp eq <4 x i8> %shuf, zeroinitializer
236 define <4 x i1> @shuf_nonzero_lhs2(<4 x i8> %xx) {
237 ; CHECK-LABEL: @shuf_nonzero_lhs2(
238 ; CHECK-NEXT: ret <4 x i1> zeroinitializer
240 %x = add nuw <4 x i8> %xx, <i8 1, i8 1, i8 1, i8 0>
242 %shuf = shufflevector <4 x i8> %x, <4 x i8> poison, <4 x i32> <i32 2, i32 0, i32 1, i32 1>
243 %r = icmp eq <4 x i8> %shuf, zeroinitializer
247 define <4 x i1> @shuf_nonzero_lhs2_fail(<4 x i8> %xx) {
248 ; CHECK-LABEL: @shuf_nonzero_lhs2_fail(
249 ; CHECK-NEXT: [[X:%.*]] = add nuw <4 x i8> [[XX:%.*]], <i8 1, i8 1, i8 1, i8 0>
250 ; CHECK-NEXT: [[SHUF:%.*]] = shufflevector <4 x i8> [[X]], <4 x i8> poison, <4 x i32> <i32 2, i32 0, i32 3, i32 1>
251 ; CHECK-NEXT: [[R:%.*]] = icmp eq <4 x i8> [[SHUF]], zeroinitializer
252 ; CHECK-NEXT: ret <4 x i1> [[R]]
254 %x = add nuw <4 x i8> %xx, <i8 1, i8 1, i8 1, i8 0>
256 %shuf = shufflevector <4 x i8> %x, <4 x i8> poison, <4 x i32> <i32 2, i32 0, i32 3, i32 1>
257 %r = icmp eq <4 x i8> %shuf, zeroinitializer
261 define <4 x i1> @shuf_nonzero_rhs(<4 x i8> %xx) {
262 ; CHECK-LABEL: @shuf_nonzero_rhs(
263 ; CHECK-NEXT: ret <4 x i1> zeroinitializer
265 %x = add nuw <4 x i8> %xx, <i8 1, i8 1, i8 1, i8 1>
267 %shuf = shufflevector <4 x i8> poison, <4 x i8> %x, <4 x i32> <i32 6, i32 7, i32 5, i32 4>
268 %r = icmp eq <4 x i8> %shuf, zeroinitializer
272 define <4 x i1> @shuf_nonzero_rhs2(<4 x i8> %xx) {
273 ; CHECK-LABEL: @shuf_nonzero_rhs2(
274 ; CHECK-NEXT: ret <4 x i1> zeroinitializer
276 %x = add nuw <4 x i8> %xx, <i8 0, i8 0, i8 1, i8 1>
278 %shuf = shufflevector <4 x i8> poison, <4 x i8> %x, <4 x i32> <i32 6, i32 7, i32 7, i32 6>
279 %r = icmp eq <4 x i8> %shuf, zeroinitializer
283 define <4 x i1> @shuf_nonzero_rhs2_fail(<4 x i8> %xx) {
284 ; CHECK-LABEL: @shuf_nonzero_rhs2_fail(
285 ; CHECK-NEXT: [[X:%.*]] = add nuw <4 x i8> [[XX:%.*]], <i8 0, i8 0, i8 1, i8 1>
286 ; CHECK-NEXT: [[SHUF:%.*]] = shufflevector <4 x i8> poison, <4 x i8> [[X]], <4 x i32> <i32 6, i32 7, i32 5, i32 6>
287 ; CHECK-NEXT: [[R:%.*]] = icmp eq <4 x i8> [[SHUF]], zeroinitializer
288 ; CHECK-NEXT: ret <4 x i1> [[R]]
290 %x = add nuw <4 x i8> %xx, <i8 0, i8 0, i8 1, i8 1>
292 %shuf = shufflevector <4 x i8> poison, <4 x i8> %x, <4 x i32> <i32 6, i32 7, i32 5, i32 6>
293 %r = icmp eq <4 x i8> %shuf, zeroinitializer
297 define <2 x i1> @insert_nonzero0(<2 x i8> %xx, i8 %yy) {
298 ; CHECK-LABEL: @insert_nonzero0(
299 ; CHECK-NEXT: ret <2 x i1> zeroinitializer
301 %x = add nuw <2 x i8> %xx, <i8 1, i8 0>
302 %y = add nuw i8 %yy, 1
304 %ins = insertelement <2 x i8> %x, i8 %y, i32 1
305 %r = icmp eq <2 x i8> %ins, zeroinitializer
309 define <2 x i1> @insert_nonzero1(<2 x i8> %xx, i8 %yy) {
310 ; CHECK-LABEL: @insert_nonzero1(
311 ; CHECK-NEXT: ret <2 x i1> zeroinitializer
313 %x = add nuw <2 x i8> %xx, <i8 0, i8 1>
314 %y = add nuw i8 %yy, 1
316 %ins = insertelement <2 x i8> %x, i8 %y, i32 0
317 %r = icmp eq <2 x i8> %ins, zeroinitializer
321 define <2 x i1> @insert_nonzero_fail(<2 x i8> %xx, i8 %yy) {
322 ; CHECK-LABEL: @insert_nonzero_fail(
323 ; CHECK-NEXT: [[X:%.*]] = add nuw <2 x i8> [[XX:%.*]], <i8 1, i8 0>
324 ; CHECK-NEXT: [[Y:%.*]] = add nuw i8 [[YY:%.*]], 1
325 ; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i8> [[X]], i8 [[Y]], i32 0
326 ; CHECK-NEXT: [[R:%.*]] = icmp eq <2 x i8> [[INS]], zeroinitializer
327 ; CHECK-NEXT: ret <2 x i1> [[R]]
329 %x = add nuw <2 x i8> %xx, <i8 1, i8 0>
330 %y = add nuw i8 %yy, 1
332 %ins = insertelement <2 x i8> %x, i8 %y, i32 0
333 %r = icmp eq <2 x i8> %ins, zeroinitializer
337 define <2 x i1> @insert_nonzero_fail2(<2 x i8> %xx, i8 %yy) {
338 ; CHECK-LABEL: @insert_nonzero_fail2(
339 ; CHECK-NEXT: [[X:%.*]] = add nuw <2 x i8> [[XX:%.*]], <i8 0, i8 1>
340 ; CHECK-NEXT: [[Y:%.*]] = add i8 [[YY:%.*]], 1
341 ; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i8> [[X]], i8 [[Y]], i32 0
342 ; CHECK-NEXT: [[R:%.*]] = icmp eq <2 x i8> [[INS]], zeroinitializer
343 ; CHECK-NEXT: ret <2 x i1> [[R]]
345 %x = add nuw <2 x i8> %xx, <i8 0, i8 1>
348 %ins = insertelement <2 x i8> %x, i8 %y, i32 0
349 %r = icmp eq <2 x i8> %ins, zeroinitializer
353 define <2 x i1> @insert_nonzero_any_idx(<2 x i8> %xx, i8 %yy, i32 %idx) {
354 ; CHECK-LABEL: @insert_nonzero_any_idx(
355 ; CHECK-NEXT: ret <2 x i1> zeroinitializer
357 %x = add nuw <2 x i8> %xx, <i8 1, i8 1>
358 %y = add nuw i8 %yy, 1
360 %ins = insertelement <2 x i8> %x, i8 %y, i32 %idx
361 %r = icmp eq <2 x i8> %ins, zeroinitializer
365 define <2 x i1> @insert_nonzero_any_idx_fail(<2 x i8> %xx, i8 %yy, i32 %idx) {
366 ; CHECK-LABEL: @insert_nonzero_any_idx_fail(
367 ; CHECK-NEXT: [[X:%.*]] = add nuw <2 x i8> [[XX:%.*]], <i8 1, i8 0>
368 ; CHECK-NEXT: [[Y:%.*]] = add nuw i8 [[YY:%.*]], 1
369 ; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i8> [[X]], i8 [[Y]], i32 [[IDX:%.*]]
370 ; CHECK-NEXT: [[R:%.*]] = icmp eq <2 x i8> [[INS]], zeroinitializer
371 ; CHECK-NEXT: ret <2 x i1> [[R]]
373 %x = add nuw <2 x i8> %xx, <i8 1, i8 0>
374 %y = add nuw i8 %yy, 1
376 %ins = insertelement <2 x i8> %x, i8 %y, i32 %idx
377 %r = icmp eq <2 x i8> %ins, zeroinitializer
381 define i1 @nonzero_reduce_or(<2 x i8> %xx) {
382 ; CHECK-LABEL: @nonzero_reduce_or(
383 ; CHECK-NEXT: ret i1 false
385 %x = add nuw <2 x i8> %xx, <i8 1, i8 1>
386 %v = call i8 @llvm.vector.reduce.or(<2 x i8> %x)
387 %r = icmp eq i8 %v, 0
391 define i1 @nonzero_reduce_or_fail(<2 x i8> %xx) {
392 ; CHECK-LABEL: @nonzero_reduce_or_fail(
393 ; CHECK-NEXT: [[X:%.*]] = add nsw <2 x i8> [[XX:%.*]], <i8 1, i8 1>
394 ; CHECK-NEXT: [[V:%.*]] = call i8 @llvm.vector.reduce.or.v2i8(<2 x i8> [[X]])
395 ; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[V]], 0
396 ; CHECK-NEXT: ret i1 [[R]]
398 %x = add nsw <2 x i8> %xx, <i8 1, i8 1>
399 %v = call i8 @llvm.vector.reduce.or(<2 x i8> %x)
400 %r = icmp eq i8 %v, 0
404 define i1 @src_x_add_x_eq_0(i8 %x) {
405 ; CHECK-LABEL: @src_x_add_x_eq_0(
406 ; CHECK-NEXT: ret i1 false
408 %x_eq_0 = icmp eq i8 %x, 0
409 %y = zext i1 %x_eq_0 to i8
411 %r = icmp eq i8 %v, 0
415 define i1 @src_x_add_x_eq_1_fail(i8 %x) {
416 ; CHECK-LABEL: @src_x_add_x_eq_1_fail(
417 ; CHECK-NEXT: [[X_EQ_1:%.*]] = icmp eq i8 [[X:%.*]], 1
418 ; CHECK-NEXT: [[Y:%.*]] = zext i1 [[X_EQ_1]] to i8
419 ; CHECK-NEXT: [[V:%.*]] = add i8 [[X]], [[Y]]
420 ; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[V]], 0
421 ; CHECK-NEXT: ret i1 [[R]]
423 %x_eq_1 = icmp eq i8 %x, 1
424 %y = zext i1 %x_eq_1 to i8
426 %r = icmp eq i8 %v, 0
430 define i1 @src_x_or_x_eq_0(i8 %x) {
431 ; CHECK-LABEL: @src_x_or_x_eq_0(
432 ; CHECK-NEXT: ret i1 false
434 %x_eq_0 = icmp eq i8 %x, 0
435 %y = sext i1 %x_eq_0 to i8
437 %r = icmp eq i8 %v, 0
441 define i1 @src_x_or_x_sle_0_fail(i8 %x) {
442 ; CHECK-LABEL: @src_x_or_x_sle_0_fail(
443 ; CHECK-NEXT: [[X_EQ_0:%.*]] = icmp sle i8 [[X:%.*]], 0
444 ; CHECK-NEXT: [[Y:%.*]] = sext i1 [[X_EQ_0]] to i8
445 ; CHECK-NEXT: [[V:%.*]] = or i8 [[X]], [[Y]]
446 ; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[V]], 0
447 ; CHECK-NEXT: ret i1 [[R]]
449 %x_eq_0 = icmp sle i8 %x, 0
450 %y = sext i1 %x_eq_0 to i8
452 %r = icmp eq i8 %v, 0
456 define i1 @src_x_xor_x_eq_0(i8 %x) {
457 ; CHECK-LABEL: @src_x_xor_x_eq_0(
458 ; CHECK-NEXT: ret i1 false
460 %x_eq_0 = icmp eq i8 %x, 0
461 %y = zext i1 %x_eq_0 to i8
463 %r = icmp eq i8 %v, 0
467 define i1 @src_x_xor_x_ne_0_fail(i8 %x) {
468 ; CHECK-LABEL: @src_x_xor_x_ne_0_fail(
469 ; CHECK-NEXT: [[X_NE_0:%.*]] = icmp ne i8 [[X:%.*]], 0
470 ; CHECK-NEXT: [[Y:%.*]] = zext i1 [[X_NE_0]] to i8
471 ; CHECK-NEXT: [[V:%.*]] = xor i8 [[X]], [[Y]]
472 ; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[V]], 0
473 ; CHECK-NEXT: ret i1 [[R]]
475 %x_ne_0 = icmp ne i8 %x, 0
476 %y = zext i1 %x_ne_0 to i8
478 %r = icmp eq i8 %v, 0
482 define i1 @src_x_sub0_x_eq_0(i8 %x) {
483 ; CHECK-LABEL: @src_x_sub0_x_eq_0(
484 ; CHECK-NEXT: ret i1 false
486 %x_eq_0 = icmp eq i8 %x, 0
487 %y = sext i1 %x_eq_0 to i8
489 %r = icmp eq i8 %v, 0
493 define i1 @src_x_sub0_z_eq_0_fail(i8 %x, i8 %z) {
494 ; CHECK-LABEL: @src_x_sub0_z_eq_0_fail(
495 ; CHECK-NEXT: [[Z_EQ_0:%.*]] = icmp eq i8 [[Z:%.*]], 0
496 ; CHECK-NEXT: [[Y:%.*]] = sext i1 [[Z_EQ_0]] to i8
497 ; CHECK-NEXT: [[V:%.*]] = sub i8 [[X:%.*]], [[Y]]
498 ; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[V]], 0
499 ; CHECK-NEXT: ret i1 [[R]]
501 %z_eq_0 = icmp eq i8 %z, 0
502 %y = sext i1 %z_eq_0 to i8
504 %r = icmp eq i8 %v, 0
508 define i1 @src_x_sub1_x_eq_0(i8 %x) {
509 ; CHECK-LABEL: @src_x_sub1_x_eq_0(
510 ; CHECK-NEXT: ret i1 false
512 %x_eq_0 = icmp eq i8 %x, 0
513 %y = zext i1 %x_eq_0 to i8
515 %r = icmp eq i8 %v, 0
519 define i1 @src_x_sub1_x_eq_0_or_fail(i8 %x, i1 %c1) {
520 ; CHECK-LABEL: @src_x_sub1_x_eq_0_or_fail(
521 ; CHECK-NEXT: [[X_EQ_0:%.*]] = icmp eq i8 [[X:%.*]], 0
522 ; CHECK-NEXT: [[X_EQ_0_OR:%.*]] = or i1 [[X_EQ_0]], [[C1:%.*]]
523 ; CHECK-NEXT: [[Y:%.*]] = zext i1 [[X_EQ_0_OR]] to i8
524 ; CHECK-NEXT: [[V:%.*]] = sub i8 [[Y]], [[X]]
525 ; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[V]], 0
526 ; CHECK-NEXT: ret i1 [[R]]
528 %x_eq_0 = icmp eq i8 %x, 0
529 %x_eq_0_or = or i1 %x_eq_0, %c1
530 %y = zext i1 %x_eq_0_or to i8
532 %r = icmp eq i8 %v, 0
536 define i1 @src_x_umax_x_eq_0(i8 %x) {
537 ; CHECK-LABEL: @src_x_umax_x_eq_0(
538 ; CHECK-NEXT: ret i1 false
540 %x_eq_0 = icmp eq i8 %x, 0
541 %y = sext i1 %x_eq_0 to i8
542 %v = call i8 @llvm.umax.i8(i8 %y, i8 %x)
543 %r = icmp eq i8 %v, 0
547 define i1 @src_x_umax_x_ugt_10_fail(i8 %x) {
548 ; CHECK-LABEL: @src_x_umax_x_ugt_10_fail(
549 ; CHECK-NEXT: [[X_UGT_10:%.*]] = icmp ugt i8 [[X:%.*]], 10
550 ; CHECK-NEXT: [[Y:%.*]] = sext i1 [[X_UGT_10]] to i8
551 ; CHECK-NEXT: [[V:%.*]] = call i8 @llvm.umax.i8(i8 [[Y]], i8 [[X]])
552 ; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[V]], 0
553 ; CHECK-NEXT: ret i1 [[R]]
555 %x_ugt_10 = icmp ugt i8 %x, 10
556 %y = sext i1 %x_ugt_10 to i8
557 %v = call i8 @llvm.umax.i8(i8 %y, i8 %x)
558 %r = icmp eq i8 %v, 0
562 define i1 @src_x_uadd.sat_x_eq_0(i8 %x) {
563 ; CHECK-LABEL: @src_x_uadd.sat_x_eq_0(
564 ; CHECK-NEXT: ret i1 false
566 %x_eq_0 = icmp eq i8 %x, 0
567 %y = zext i1 %x_eq_0 to i8
568 %v = call i8 @llvm.uadd.sat.i8(i8 %y, i8 %x)
569 %r = icmp eq i8 %v, 0
573 define i1 @src_x_uadd.sat_c1_fail(i8 %x, i1 %c1) {
574 ; CHECK-LABEL: @src_x_uadd.sat_c1_fail(
575 ; CHECK-NEXT: [[Y:%.*]] = zext i1 [[C1:%.*]] to i8
576 ; CHECK-NEXT: [[V:%.*]] = call i8 @llvm.uadd.sat.i8(i8 [[Y]], i8 [[X:%.*]])
577 ; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[V]], 0
578 ; CHECK-NEXT: ret i1 [[R]]
580 %y = zext i1 %c1 to i8
581 %v = call i8 @llvm.uadd.sat.i8(i8 %y, i8 %x)
582 %r = icmp eq i8 %v, 0