1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=instcombine < %s -S | FileCheck %s
4 define i8 @phi_ugt_high_bits(i8 %x) {
5 ; CHECK-LABEL: @phi_ugt_high_bits(
7 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[X:%.*]], -65
8 ; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
10 ; CHECK-NEXT: ret i8 64
12 ; CHECK-NEXT: br label [[T]]
15 %cmp = icmp ugt i8 %x, 191
16 br i1 %cmp, label %T, label %F
18 %v = phi i8 [ %x, %entry], [-1, %F]
25 define i8 @phi_ult_low_bits(i8 %x) {
26 ; CHECK-LABEL: @phi_ult_low_bits(
28 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[X:%.*]], -64
29 ; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
31 ; CHECK-NEXT: br label [[F]]
33 ; CHECK-NEXT: ret i8 64
36 %cmp = icmp ult i8 %x, 192
37 br i1 %cmp, label %T, label %F
41 %v = phi i8 [ %x, %entry], [-1, %T]
46 define i8 @phi_ugt_high_bits_fail(i8 %x) {
47 ; CHECK-LABEL: @phi_ugt_high_bits_fail(
49 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[X:%.*]], -66
50 ; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
52 ; CHECK-NEXT: [[V:%.*]] = phi i8 [ [[X]], [[ENTRY:%.*]] ], [ -1, [[F]] ]
53 ; CHECK-NEXT: [[R:%.*]] = and i8 [[V]], 64
54 ; CHECK-NEXT: ret i8 [[R]]
56 ; CHECK-NEXT: br label [[T]]
59 %cmp = icmp ugt i8 %x, 190
60 br i1 %cmp, label %T, label %F
62 %v = phi i8 [ %x, %entry], [-1, %F]
69 define i8 @phi_uge_high_bits(i8 %x) {
70 ; CHECK-LABEL: @phi_uge_high_bits(
72 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[X:%.*]], -65
73 ; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
75 ; CHECK-NEXT: ret i8 64
77 ; CHECK-NEXT: br label [[T]]
80 %cmp = icmp uge i8 %x, 192
81 br i1 %cmp, label %T, label %F
83 %v = phi i8 [ %x, %entry], [-1, %F]
90 define i8 @phi_uge_high_bits_fail(i8 %x) {
91 ; CHECK-LABEL: @phi_uge_high_bits_fail(
93 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[X:%.*]], 5
94 ; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
96 ; CHECK-NEXT: [[V:%.*]] = phi i8 [ [[X]], [[ENTRY:%.*]] ], [ -1, [[F]] ]
97 ; CHECK-NEXT: [[R:%.*]] = and i8 [[V]], 1
98 ; CHECK-NEXT: ret i8 [[R]]
100 ; CHECK-NEXT: br label [[T]]
103 %cmp = icmp ugt i8 %x, 5
104 br i1 %cmp, label %T, label %F
106 %v = phi i8 [ %x, %entry], [-1, %F]
113 define i8 @phi_sge_high_bits(i8 %x) {
114 ; CHECK-LABEL: @phi_sge_high_bits(
116 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[X:%.*]], 95
117 ; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
119 ; CHECK-NEXT: ret i8 96
121 ; CHECK-NEXT: br label [[T]]
124 %cmp = icmp sge i8 %x, 96
125 br i1 %cmp, label %T, label %F
127 %v = phi i8 [ %x, %entry], [-1, %F]
134 define i8 @phi_sge_high_bits_fail(i8 %x) {
135 ; CHECK-LABEL: @phi_sge_high_bits_fail(
137 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[X:%.*]], -2
138 ; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
140 ; CHECK-NEXT: [[V:%.*]] = phi i8 [ [[X]], [[ENTRY:%.*]] ], [ -1, [[F]] ]
141 ; CHECK-NEXT: [[R:%.*]] = and i8 [[V]], 1
142 ; CHECK-NEXT: ret i8 [[R]]
144 ; CHECK-NEXT: br label [[T]]
147 %cmp = icmp sge i8 %x, -1
148 br i1 %cmp, label %T, label %F
150 %v = phi i8 [ %x, %entry], [-1, %F]
157 define i8 @phi_sgt_high_bits(i8 %x) {
158 ; CHECK-LABEL: @phi_sgt_high_bits(
160 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[X:%.*]], -1
161 ; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
163 ; CHECK-NEXT: ret i8 0
165 ; CHECK-NEXT: br label [[T]]
168 %cmp = icmp sgt i8 %x, -1
169 br i1 %cmp, label %T, label %F
171 %v = phi i8 [ %x, %entry], [0, %F]
178 define i8 @phi_sgt_high_bits2(i8 %x) {
179 ; CHECK-LABEL: @phi_sgt_high_bits2(
181 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[X:%.*]], 63
182 ; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
184 ; CHECK-NEXT: ret i8 64
186 ; CHECK-NEXT: br label [[T]]
189 %cmp = icmp sgt i8 %x, 63
190 br i1 %cmp, label %T, label %F
192 %v = phi i8 [ %x, %entry], [-1, %F]
199 define i8 @phi_sgt_high_bits_fail(i8 %x) {
200 ; CHECK-LABEL: @phi_sgt_high_bits_fail(
202 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[X:%.*]], 62
203 ; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
205 ; CHECK-NEXT: [[V:%.*]] = phi i8 [ [[X]], [[ENTRY:%.*]] ], [ -1, [[F]] ]
206 ; CHECK-NEXT: [[R:%.*]] = and i8 [[V]], 64
207 ; CHECK-NEXT: ret i8 [[R]]
209 ; CHECK-NEXT: br label [[T]]
212 %cmp = icmp sgt i8 %x, 62
213 br i1 %cmp, label %T, label %F
215 %v = phi i8 [ %x, %entry], [-1, %F]
222 define i8 @phi_slt_high_bits(i8 %x) {
223 ; CHECK-LABEL: @phi_slt_high_bits(
225 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X:%.*]], 0
226 ; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
228 ; CHECK-NEXT: ret i8 -128
230 ; CHECK-NEXT: br label [[T]]
233 %cmp = icmp slt i8 %x, 0
234 br i1 %cmp, label %T, label %F
236 %v = phi i8 [ %x, %entry], [-1, %F]
243 define i8 @phi_slt_high_bits2(i8 %x) {
244 ; CHECK-LABEL: @phi_slt_high_bits2(
246 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X:%.*]], -64
247 ; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
249 ; CHECK-NEXT: ret i8 0
251 ; CHECK-NEXT: br label [[T]]
254 %cmp = icmp slt i8 %x, -64
255 br i1 %cmp, label %T, label %F
257 %v = phi i8 [ %x, %entry], [0, %F]
264 define i8 @phi_slt_high_bits_fail(i8 %x) {
265 ; CHECK-LABEL: @phi_slt_high_bits_fail(
267 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X:%.*]], -63
268 ; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
270 ; CHECK-NEXT: [[V:%.*]] = phi i8 [ [[X]], [[ENTRY:%.*]] ], [ 0, [[F]] ]
271 ; CHECK-NEXT: [[R:%.*]] = and i8 [[V]], 64
272 ; CHECK-NEXT: ret i8 [[R]]
274 ; CHECK-NEXT: br label [[T]]
277 %cmp = icmp slt i8 %x, -63
278 br i1 %cmp, label %T, label %F
280 %v = phi i8 [ %x, %entry], [0, %F]
287 define i8 @phi_sle_high_bits(i8 %x) {
288 ; CHECK-LABEL: @phi_sle_high_bits(
290 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X:%.*]], -64
291 ; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
293 ; CHECK-NEXT: ret i8 0
295 ; CHECK-NEXT: br label [[T]]
298 %cmp = icmp sle i8 %x, -65
299 br i1 %cmp, label %T, label %F
301 %v = phi i8 [ %x, %entry], [0, %F]
308 define i8 @phi_sle_low_bits(i8 %x) {
309 ; CHECK-LABEL: @phi_sle_low_bits(
311 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X:%.*]], 65
312 ; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
314 ; CHECK-NEXT: br label [[F]]
316 ; CHECK-NEXT: ret i8 64
319 %cmp = icmp sle i8 %x, 64
320 br i1 %cmp, label %T, label %F
324 %v = phi i8 [ %x, %entry], [-1, %T]
329 define i8 @phi_sle_high_bits_fail(i8 %x) {
330 ; CHECK-LABEL: @phi_sle_high_bits_fail(
332 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X:%.*]], 1
333 ; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
335 ; CHECK-NEXT: [[V:%.*]] = phi i8 [ [[X]], [[ENTRY:%.*]] ], [ -1, [[F]] ]
336 ; CHECK-NEXT: [[R:%.*]] = and i8 [[V]], -128
337 ; CHECK-NEXT: ret i8 [[R]]
339 ; CHECK-NEXT: br label [[T]]
342 %cmp = icmp sle i8 %x, 0
343 br i1 %cmp, label %T, label %F
345 %v = phi i8 [ %x, %entry], [-1, %F]
352 define i8 @phi_sle_high_bits_fail2(i8 %x) {
353 ; CHECK-LABEL: @phi_sle_high_bits_fail2(
355 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X:%.*]], -63
356 ; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
358 ; CHECK-NEXT: [[V:%.*]] = phi i8 [ [[X]], [[ENTRY:%.*]] ], [ -1, [[F]] ]
359 ; CHECK-NEXT: [[R:%.*]] = and i8 [[V]], 64
360 ; CHECK-NEXT: ret i8 [[R]]
362 ; CHECK-NEXT: br label [[T]]
365 %cmp = icmp sle i8 %x, -64
366 br i1 %cmp, label %T, label %F
368 %v = phi i8 [ %x, %entry], [-1, %F]
375 define i8 @phi_ugt_high_bits_and_known(i8 %xx) {
376 ; CHECK-LABEL: @phi_ugt_high_bits_and_known(
378 ; CHECK-NEXT: [[X:%.*]] = or i8 [[XX:%.*]], 1
379 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[XX]], -65
380 ; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
382 ; CHECK-NEXT: [[V:%.*]] = phi i8 [ [[X]], [[ENTRY:%.*]] ], [ -1, [[F]] ]
383 ; CHECK-NEXT: [[R:%.*]] = and i8 [[V]], 65
384 ; CHECK-NEXT: ret i8 [[R]]
386 ; CHECK-NEXT: br label [[T]]
390 %cmp = icmp ugt i8 %x, 191
391 br i1 %cmp, label %T, label %F
393 %v = phi i8 [ %x, %entry], [-1, %F]
400 define i8 @phi_ugt_high_bits_and_known_todo_high_depths(i8 %xx, i8 %y, i8 %z) {
401 ; CHECK-LABEL: @phi_ugt_high_bits_and_known_todo_high_depths(
403 ; CHECK-NEXT: [[YY:%.*]] = and i8 [[Y:%.*]], -2
404 ; CHECK-NEXT: [[XXX:%.*]] = and i8 [[XX:%.*]], [[YY]]
405 ; CHECK-NEXT: [[ZZ:%.*]] = or i8 [[Z:%.*]], 1
406 ; CHECK-NEXT: [[X:%.*]] = add i8 [[XXX]], [[ZZ]]
407 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[X]], -65
408 ; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
410 ; CHECK-NEXT: [[V:%.*]] = phi i8 [ [[X]], [[ENTRY:%.*]] ], [ -1, [[F]] ]
411 ; CHECK-NEXT: [[R:%.*]] = and i8 [[V]], 65
412 ; CHECK-NEXT: ret i8 [[R]]
414 ; CHECK-NEXT: br label [[T]]
418 %xxx = and i8 %xx, %yy
420 %x = add i8 %xxx, %zz
421 %cmp = icmp ugt i8 %x, 191
422 br i1 %cmp, label %T, label %F
424 %v = phi i8 [ %x, %entry], [-1, %F]
431 ;Illustrate if 2 pointers are non-equal when one of them is a recursive GEP.
432 ;Cases which folds to a canonical icmp(ptr1, ptr2)
433 define i1 @recursiveGEP_withPtrSub1(ptr %val1) {
434 ; CHECK-LABEL: @recursiveGEP_withPtrSub1(
436 ; CHECK-NEXT: br label [[WHILE_COND_I:%.*]]
437 ; CHECK: while.cond.i:
438 ; CHECK-NEXT: [[A_PN_I:%.*]] = phi ptr [ [[TEST_0_I:%.*]], [[WHILE_COND_I]] ], [ [[VAL1:%.*]], [[ENTRY:%.*]] ]
439 ; CHECK-NEXT: [[TEST_0_I]] = getelementptr inbounds i8, ptr [[A_PN_I]], i64 1
440 ; CHECK-NEXT: [[TMP0:%.*]] = load i8, ptr [[TEST_0_I]], align 2
441 ; CHECK-NEXT: [[CMP3_NOT_I:%.*]] = icmp eq i8 [[TMP0]], 0
442 ; CHECK-NEXT: br i1 [[CMP3_NOT_I]], label [[WHILE_END_I:%.*]], label [[WHILE_COND_I]]
443 ; CHECK: while.end.i:
444 ; CHECK-NEXT: ret i1 false
447 br label %while.cond.i
450 %a.pn.i = phi ptr [ %test.0.i, %while.cond.i ], [ %val1, %entry ]
451 %test.0.i = getelementptr inbounds i8, ptr %a.pn.i, i64 1
452 %0 = load i8, ptr %test.0.i, align 2
453 %cmp3.not.i = icmp eq i8 %0, 0
454 br i1 %cmp3.not.i, label %while.end.i, label %while.cond.i
457 %sub.ptr.lhs.cast.i = ptrtoint ptr %test.0.i to i64
458 %sub.ptr.rhs.cast.i = ptrtoint ptr %val1 to i64
459 %sub.ptr.sub.i = sub i64 %sub.ptr.lhs.cast.i, %sub.ptr.rhs.cast.i
460 %bool = icmp eq i64 %sub.ptr.sub.i, 0
464 define i1 @recursiveGEP_withPtrSub1_PhiOperandsCommuted(ptr %val1) {
465 ; CHECK-LABEL: @recursiveGEP_withPtrSub1_PhiOperandsCommuted(
467 ; CHECK-NEXT: br label [[WHILE_COND_I:%.*]]
468 ; CHECK: while.cond.i:
469 ; CHECK-NEXT: [[A_PN_I:%.*]] = phi ptr [ [[VAL1:%.*]], [[ENTRY:%.*]] ], [ [[TEST_0_I:%.*]], [[WHILE_COND_I]] ]
470 ; CHECK-NEXT: [[TEST_0_I]] = getelementptr inbounds i8, ptr [[A_PN_I]], i64 1
471 ; CHECK-NEXT: [[TMP0:%.*]] = load i8, ptr [[TEST_0_I]], align 2
472 ; CHECK-NEXT: [[CMP3_NOT_I:%.*]] = icmp eq i8 [[TMP0]], 0
473 ; CHECK-NEXT: br i1 [[CMP3_NOT_I]], label [[WHILE_END_I:%.*]], label [[WHILE_COND_I]]
474 ; CHECK: while.end.i:
475 ; CHECK-NEXT: ret i1 false
478 br label %while.cond.i
481 %a.pn.i = phi ptr [ %val1, %entry ], [ %test.0.i, %while.cond.i ]
482 %test.0.i = getelementptr inbounds i8, ptr %a.pn.i, i64 1
483 %0 = load i8, ptr %test.0.i, align 2
484 %cmp3.not.i = icmp eq i8 %0, 0
485 br i1 %cmp3.not.i, label %while.end.i, label %while.cond.i
488 %sub.ptr.lhs.cast.i = ptrtoint ptr %test.0.i to i64
489 %sub.ptr.rhs.cast.i = ptrtoint ptr %val1 to i64
490 %sub.ptr.sub.i = sub i64 %sub.ptr.lhs.cast.i, %sub.ptr.rhs.cast.i
491 %bool = icmp eq i64 %sub.ptr.sub.i, 0
495 define i1 @recursiveGEP_withPtrSub1_SubOperandsCommuted(ptr %val1) {
496 ; CHECK-LABEL: @recursiveGEP_withPtrSub1_SubOperandsCommuted(
498 ; CHECK-NEXT: br label [[WHILE_COND_I:%.*]]
499 ; CHECK: while.cond.i:
500 ; CHECK-NEXT: [[A_PN_I:%.*]] = phi ptr [ [[TEST_0_I:%.*]], [[WHILE_COND_I]] ], [ [[VAL1:%.*]], [[ENTRY:%.*]] ]
501 ; CHECK-NEXT: [[TEST_0_I]] = getelementptr inbounds i8, ptr [[A_PN_I]], i64 1
502 ; CHECK-NEXT: [[TMP0:%.*]] = load i8, ptr [[TEST_0_I]], align 2
503 ; CHECK-NEXT: [[CMP3_NOT_I:%.*]] = icmp eq i8 [[TMP0]], 0
504 ; CHECK-NEXT: br i1 [[CMP3_NOT_I]], label [[WHILE_END_I:%.*]], label [[WHILE_COND_I]]
505 ; CHECK: while.end.i:
506 ; CHECK-NEXT: ret i1 false
509 br label %while.cond.i
512 %a.pn.i = phi ptr [ %test.0.i, %while.cond.i ], [ %val1, %entry ]
513 %test.0.i = getelementptr inbounds i8, ptr %a.pn.i, i64 1
514 %0 = load i8, ptr %test.0.i, align 2
515 %cmp3.not.i = icmp eq i8 %0, 0
516 br i1 %cmp3.not.i, label %while.end.i, label %while.cond.i
519 %sub.ptr.lhs.cast.i = ptrtoint ptr %test.0.i to i64
520 %sub.ptr.rhs.cast.i = ptrtoint ptr %val1 to i64
521 %sub.ptr.sub.i = sub i64 %sub.ptr.rhs.cast.i, %sub.ptr.lhs.cast.i
522 %bool = icmp eq i64 %sub.ptr.sub.i, 0
526 define i1 @recursiveGEP_withPtrSub2(ptr %val1) {
527 ; CHECK-LABEL: @recursiveGEP_withPtrSub2(
529 ; CHECK-NEXT: br label [[WHILE_COND_I:%.*]]
530 ; CHECK: while.cond.i:
531 ; CHECK-NEXT: [[A_PN_I:%.*]] = phi ptr [ [[TEST_0_I:%.*]], [[WHILE_COND_I]] ], [ [[VAL1:%.*]], [[ENTRY:%.*]] ]
532 ; CHECK-NEXT: [[TEST_0_I]] = getelementptr inbounds i8, ptr [[A_PN_I]], i64 -1
533 ; CHECK-NEXT: [[TMP0:%.*]] = load i8, ptr [[TEST_0_I]], align 2
534 ; CHECK-NEXT: [[CMP3_NOT_I:%.*]] = icmp eq i8 [[TMP0]], 0
535 ; CHECK-NEXT: br i1 [[CMP3_NOT_I]], label [[WHILE_END_I:%.*]], label [[WHILE_COND_I]]
536 ; CHECK: while.end.i:
537 ; CHECK-NEXT: ret i1 false
540 br label %while.cond.i
543 %a.pn.i = phi ptr [ %test.0.i, %while.cond.i ], [ %val1, %entry ]
544 %test.0.i = getelementptr inbounds i8, ptr %a.pn.i, i64 -1
545 %0 = load i8, ptr %test.0.i, align 2
546 %cmp3.not.i = icmp eq i8 %0, 0
547 br i1 %cmp3.not.i, label %while.end.i, label %while.cond.i
550 %sub.ptr.lhs.cast.i = ptrtoint ptr %test.0.i to i64
551 %sub.ptr.rhs.cast.i = ptrtoint ptr %val1 to i64
552 %sub.ptr.sub.i = sub i64 %sub.ptr.lhs.cast.i, %sub.ptr.rhs.cast.i
553 %bool = icmp eq i64 %sub.ptr.sub.i, 0
557 define i1 @recursiveGEP_withPtrSub3(ptr %val1) {
558 ; CHECK-LABEL: @recursiveGEP_withPtrSub3(
560 ; CHECK-NEXT: [[TEST_VAL1:%.*]] = getelementptr inbounds i8, ptr [[VAL1:%.*]], i64 7
561 ; CHECK-NEXT: br label [[WHILE_COND_I:%.*]]
562 ; CHECK: while.cond.i:
563 ; CHECK-NEXT: [[A_PN_I:%.*]] = phi ptr [ [[TEST_0_I:%.*]], [[WHILE_COND_I]] ], [ [[TEST_VAL1]], [[ENTRY:%.*]] ]
564 ; CHECK-NEXT: [[TEST_0_I]] = getelementptr inbounds i8, ptr [[A_PN_I]], i64 1
565 ; CHECK-NEXT: [[TMP0:%.*]] = load i8, ptr [[TEST_0_I]], align 2
566 ; CHECK-NEXT: [[CMP3_NOT_I:%.*]] = icmp eq i8 [[TMP0]], 0
567 ; CHECK-NEXT: br i1 [[CMP3_NOT_I]], label [[WHILE_END_I:%.*]], label [[WHILE_COND_I]]
568 ; CHECK: while.end.i:
569 ; CHECK-NEXT: ret i1 false
572 %test.val1 = getelementptr inbounds i8, ptr %val1, i64 7
573 br label %while.cond.i
576 %a.pn.i = phi ptr [ %test.0.i, %while.cond.i ], [ %test.val1, %entry ]
577 %test.0.i = getelementptr inbounds i8, ptr %a.pn.i, i64 1
578 %0 = load i8, ptr %test.0.i, align 2
579 %cmp3.not.i = icmp eq i8 %0, 0
580 br i1 %cmp3.not.i, label %while.end.i, label %while.cond.i
583 %sub.ptr.lhs.cast.i = ptrtoint ptr %test.0.i to i64
584 %1 = getelementptr inbounds i8, ptr %val1, i64 5
585 %sub.ptr.rhs.cast.i = ptrtoint ptr %1 to i64
586 %sub.ptr.sub.i = sub i64 %sub.ptr.lhs.cast.i, %sub.ptr.rhs.cast.i
587 %bool = icmp eq i64 %sub.ptr.sub.i, 0
591 define i1 @recursiveGEP_withPtrSub1_notKnownNonEqual1(ptr %val1, i64 %val2) {
592 ; CHECK-LABEL: @recursiveGEP_withPtrSub1_notKnownNonEqual1(
594 ; CHECK-NEXT: br label [[WHILE_COND_I:%.*]]
595 ; CHECK: while.cond.i:
596 ; CHECK-NEXT: [[A_PN_I:%.*]] = phi ptr [ [[TEST_0_I:%.*]], [[WHILE_COND_I]] ], [ [[VAL1:%.*]], [[ENTRY:%.*]] ]
597 ; CHECK-NEXT: [[TEST_0_I]] = getelementptr inbounds i8, ptr [[A_PN_I]], i64 1
598 ; CHECK-NEXT: [[TMP0:%.*]] = load i8, ptr [[TEST_0_I]], align 2
599 ; CHECK-NEXT: [[CMP3_NOT_I:%.*]] = icmp eq i8 [[TMP0]], 0
600 ; CHECK-NEXT: br i1 [[CMP3_NOT_I]], label [[WHILE_END_I:%.*]], label [[WHILE_COND_I]]
601 ; CHECK: while.end.i:
602 ; CHECK-NEXT: [[TMP1:%.*]] = getelementptr inbounds i8, ptr [[VAL1]], i64 [[VAL2:%.*]]
603 ; CHECK-NEXT: [[BOOL:%.*]] = icmp eq ptr [[TEST_0_I]], [[TMP1]]
604 ; CHECK-NEXT: ret i1 [[BOOL]]
607 br label %while.cond.i
610 %a.pn.i = phi ptr [ %test.0.i, %while.cond.i ], [ %val1, %entry ]
611 %test.0.i = getelementptr inbounds i8, ptr %a.pn.i, i64 1
612 %0 = load i8, ptr %test.0.i, align 2
613 %cmp3.not.i = icmp eq i8 %0, 0
614 br i1 %cmp3.not.i, label %while.end.i, label %while.cond.i
617 %sub.ptr.lhs.cast.i = ptrtoint ptr %test.0.i to i64
618 %1 = getelementptr inbounds i8, ptr %val1, i64 %val2
619 %sub.ptr.rhs.cast.i = ptrtoint ptr %1 to i64
620 %sub.ptr.sub.i = sub i64 %sub.ptr.lhs.cast.i, %sub.ptr.rhs.cast.i
621 %bool = icmp eq i64 %sub.ptr.sub.i, 0
625 define i1 @recursiveGEP_withPtrSub1_notKnownNonEqual2(ptr %val1) {
626 ; CHECK-LABEL: @recursiveGEP_withPtrSub1_notKnownNonEqual2(
628 ; CHECK-NEXT: [[TEST_VAL1:%.*]] = getelementptr inbounds i8, ptr [[VAL1:%.*]], i64 -1
629 ; CHECK-NEXT: br label [[WHILE_COND_I:%.*]]
630 ; CHECK: while.cond.i:
631 ; CHECK-NEXT: [[A_PN_I:%.*]] = phi ptr [ [[TEST_0_I:%.*]], [[WHILE_COND_I]] ], [ [[TEST_VAL1]], [[ENTRY:%.*]] ]
632 ; CHECK-NEXT: [[TEST_0_I]] = getelementptr inbounds i8, ptr [[A_PN_I]], i64 1
633 ; CHECK-NEXT: [[TMP0:%.*]] = load i8, ptr [[TEST_0_I]], align 2
634 ; CHECK-NEXT: [[CMP3_NOT_I:%.*]] = icmp eq i8 [[TMP0]], 0
635 ; CHECK-NEXT: br i1 [[CMP3_NOT_I]], label [[WHILE_END_I:%.*]], label [[WHILE_COND_I]]
636 ; CHECK: while.end.i:
637 ; CHECK-NEXT: [[BOOL:%.*]] = icmp eq ptr [[TEST_0_I]], [[VAL1]]
638 ; CHECK-NEXT: ret i1 [[BOOL]]
641 %test.val1 = getelementptr inbounds i8, ptr %val1, i64 -1
642 br label %while.cond.i
645 %a.pn.i = phi ptr [ %test.0.i, %while.cond.i ], [ %test.val1, %entry ]
646 %test.0.i = getelementptr inbounds i8, ptr %a.pn.i, i64 1
647 %0 = load i8, ptr %test.0.i, align 2
648 %cmp3.not.i = icmp eq i8 %0, 0
649 br i1 %cmp3.not.i, label %while.end.i, label %while.cond.i
652 %sub.ptr.lhs.cast.i = ptrtoint ptr %test.0.i to i64
653 %sub.ptr.rhs.cast.i = ptrtoint ptr %val1 to i64
654 %sub.ptr.sub.i = sub i64 %sub.ptr.lhs.cast.i, %sub.ptr.rhs.cast.i
655 %bool = icmp eq i64 %sub.ptr.sub.i, 0
659 define i1 @recursiveGEP_withPtrSub1_notKnownNonEqual3(ptr %val1) {
660 ; CHECK-LABEL: @recursiveGEP_withPtrSub1_notKnownNonEqual3(
662 ; CHECK-NEXT: [[TEST_VAL1:%.*]] = getelementptr inbounds i8, ptr [[VAL1:%.*]], i64 5
663 ; CHECK-NEXT: br label [[WHILE_COND_I:%.*]]
664 ; CHECK: while.cond.i:
665 ; CHECK-NEXT: [[A_PN_I:%.*]] = phi ptr [ [[TEST_0_I:%.*]], [[WHILE_COND_I]] ], [ [[TEST_VAL1]], [[ENTRY:%.*]] ]
666 ; CHECK-NEXT: [[TEST_0_I]] = getelementptr inbounds i8, ptr [[A_PN_I]], i64 -1
667 ; CHECK-NEXT: [[TMP0:%.*]] = load i8, ptr [[TEST_0_I]], align 2
668 ; CHECK-NEXT: [[CMP3_NOT_I:%.*]] = icmp eq i8 [[TMP0]], 0
669 ; CHECK-NEXT: br i1 [[CMP3_NOT_I]], label [[WHILE_END_I:%.*]], label [[WHILE_COND_I]]
670 ; CHECK: while.end.i:
671 ; CHECK-NEXT: [[BOOL:%.*]] = icmp eq ptr [[TEST_0_I]], [[VAL1]]
672 ; CHECK-NEXT: ret i1 [[BOOL]]
675 %test.val1 = getelementptr inbounds i8, ptr %val1, i64 5
676 br label %while.cond.i
679 %a.pn.i = phi ptr [ %test.0.i, %while.cond.i ], [ %test.val1, %entry ]
680 %test.0.i = getelementptr inbounds i8, ptr %a.pn.i, i64 -1
681 %0 = load i8, ptr %test.0.i, align 2
682 %cmp3.not.i = icmp eq i8 %0, 0
683 br i1 %cmp3.not.i, label %while.end.i, label %while.cond.i
686 %sub.ptr.lhs.cast.i = ptrtoint ptr %test.0.i to i64
687 %sub.ptr.rhs.cast.i = ptrtoint ptr %val1 to i64
688 %sub.ptr.sub.i = sub i64 %sub.ptr.lhs.cast.i, %sub.ptr.rhs.cast.i
689 %bool = icmp eq i64 %sub.ptr.sub.i, 0
693 define i1 @recursiveGEP_withPtrSub_maybeZero(ptr %val1) {
694 ; CHECK-LABEL: @recursiveGEP_withPtrSub_maybeZero(
696 ; CHECK-NEXT: br label [[WHILE_COND_I:%.*]]
697 ; CHECK: while.cond.i:
698 ; CHECK-NEXT: [[A_PN_I:%.*]] = phi ptr [ [[TEST_0_I:%.*]], [[WHILE_COND_I]] ], [ [[VAL1:%.*]], [[ENTRY:%.*]] ]
699 ; CHECK-NEXT: [[TMP0:%.*]] = load i8, ptr [[A_PN_I]], align 2
700 ; CHECK-NEXT: [[TEST_0_I]] = getelementptr inbounds i8, ptr [[A_PN_I]], i64 1
701 ; CHECK-NEXT: [[CMP3_NOT_I:%.*]] = icmp eq i8 [[TMP0]], 0
702 ; CHECK-NEXT: br i1 [[CMP3_NOT_I]], label [[WHILE_END_I:%.*]], label [[WHILE_COND_I]]
703 ; CHECK: while.end.i:
704 ; CHECK-NEXT: [[BOOL:%.*]] = icmp eq ptr [[A_PN_I]], [[VAL1]]
705 ; CHECK-NEXT: ret i1 [[BOOL]]
708 br label %while.cond.i
711 %a.pn.i = phi ptr [ %test.0.i, %while.cond.i ], [ %val1, %entry ]
712 %0 = load i8, ptr %a.pn.i, align 2
713 %test.0.i = getelementptr inbounds i8, ptr %a.pn.i, i64 1
714 %cmp3.not.i = icmp eq i8 %0, 0
715 br i1 %cmp3.not.i, label %while.end.i, label %while.cond.i
718 %sub.ptr.lhs.cast.i = ptrtoint ptr %a.pn.i to i64
719 %sub.ptr.rhs.cast.i = ptrtoint ptr %val1 to i64
720 %sub.ptr.sub.i = sub i64 %sub.ptr.lhs.cast.i, %sub.ptr.rhs.cast.i
721 %bool = icmp eq i64 %sub.ptr.sub.i, 0
726 ;Test where Step is non-inbound.
727 define i1 @recursiveGEP_withPtrSub_noninboundStep1(ptr %val1) {
728 ; CHECK-LABEL: @recursiveGEP_withPtrSub_noninboundStep1(
730 ; CHECK-NEXT: br label [[WHILE_COND_I:%.*]]
731 ; CHECK: while.cond.i:
732 ; CHECK-NEXT: [[A_PN_I:%.*]] = phi ptr [ [[TEST_0_I:%.*]], [[WHILE_COND_I]] ], [ [[VAL1:%.*]], [[ENTRY:%.*]] ]
733 ; CHECK-NEXT: [[TEST_0_I]] = getelementptr i8, ptr [[A_PN_I]], i64 1
734 ; CHECK-NEXT: [[TMP0:%.*]] = load i8, ptr [[TEST_0_I]], align 2
735 ; CHECK-NEXT: [[CMP3_NOT_I:%.*]] = icmp eq i8 [[TMP0]], 0
736 ; CHECK-NEXT: br i1 [[CMP3_NOT_I]], label [[WHILE_END_I:%.*]], label [[WHILE_COND_I]]
737 ; CHECK: while.end.i:
738 ; CHECK-NEXT: [[BOOL:%.*]] = icmp eq ptr [[TEST_0_I]], [[VAL1]]
739 ; CHECK-NEXT: ret i1 [[BOOL]]
742 br label %while.cond.i
745 %a.pn.i = phi ptr [ %test.0.i, %while.cond.i ], [ %val1, %entry ]
746 %test.0.i = getelementptr i8, ptr %a.pn.i, i64 1
747 %0 = load i8, ptr %test.0.i, align 2
748 %cmp3.not.i = icmp eq i8 %0, 0
749 br i1 %cmp3.not.i, label %while.end.i, label %while.cond.i
752 %sub.ptr.lhs.cast.i = ptrtoint ptr %test.0.i to i64
753 %sub.ptr.rhs.cast.i = ptrtoint ptr %val1 to i64
754 %sub.ptr.sub.i = sub i64 %sub.ptr.lhs.cast.i, %sub.ptr.rhs.cast.i
755 %bool = icmp eq i64 %sub.ptr.sub.i, 0
759 define i1 @recursiveGEP_withPtrSub_noninboundStep2(ptr %val1) {
760 ; CHECK-LABEL: @recursiveGEP_withPtrSub_noninboundStep2(
762 ; CHECK-NEXT: br label [[WHILE_COND_I:%.*]]
763 ; CHECK: while.cond.i:
764 ; CHECK-NEXT: [[A_PN_I:%.*]] = phi ptr [ [[TEST_0_I:%.*]], [[WHILE_COND_I]] ], [ [[VAL1:%.*]], [[ENTRY:%.*]] ]
765 ; CHECK-NEXT: [[TEST_0_I]] = getelementptr i8, ptr [[A_PN_I]], i64 -1
766 ; CHECK-NEXT: [[TMP0:%.*]] = load i8, ptr [[TEST_0_I]], align 2
767 ; CHECK-NEXT: [[CMP3_NOT_I:%.*]] = icmp eq i8 [[TMP0]], 0
768 ; CHECK-NEXT: br i1 [[CMP3_NOT_I]], label [[WHILE_END_I:%.*]], label [[WHILE_COND_I]]
769 ; CHECK: while.end.i:
770 ; CHECK-NEXT: [[BOOL:%.*]] = icmp eq ptr [[TEST_0_I]], [[VAL1]]
771 ; CHECK-NEXT: ret i1 [[BOOL]]
774 br label %while.cond.i
777 %a.pn.i = phi ptr [ %test.0.i, %while.cond.i ], [ %val1, %entry ]
778 %test.0.i = getelementptr i8, ptr %a.pn.i, i64 -1
779 %0 = load i8, ptr %test.0.i, align 2
780 %cmp3.not.i = icmp eq i8 %0, 0
781 br i1 %cmp3.not.i, label %while.end.i, label %while.cond.i
784 %sub.ptr.lhs.cast.i = ptrtoint ptr %test.0.i to i64
785 %sub.ptr.rhs.cast.i = ptrtoint ptr %val1 to i64
786 %sub.ptr.sub.i = sub i64 %sub.ptr.lhs.cast.i, %sub.ptr.rhs.cast.i
787 %bool = icmp eq i64 %sub.ptr.sub.i, 0
791 ;Test where Step and GEP B are non-inbound.
792 define i1 @recursiveGEP_withPtrSub_noninboundStepAndB(ptr %val1) {
793 ; CHECK-LABEL: @recursiveGEP_withPtrSub_noninboundStepAndB(
795 ; CHECK-NEXT: [[TEST:%.*]] = getelementptr inbounds i8, ptr [[VAL1:%.*]], i64 2
796 ; CHECK-NEXT: br label [[WHILE_COND_I:%.*]]
797 ; CHECK: while.cond.i:
798 ; CHECK-NEXT: [[A_PN_I:%.*]] = phi ptr [ [[TEST_0_I:%.*]], [[WHILE_COND_I]] ], [ [[TEST]], [[ENTRY:%.*]] ]
799 ; CHECK-NEXT: [[TEST_0_I]] = getelementptr i8, ptr [[A_PN_I]], i64 1
800 ; CHECK-NEXT: [[TMP0:%.*]] = load i8, ptr [[TEST_0_I]], align 2
801 ; CHECK-NEXT: [[CMP3_NOT_I:%.*]] = icmp eq i8 [[TMP0]], 0
802 ; CHECK-NEXT: br i1 [[CMP3_NOT_I]], label [[WHILE_END_I:%.*]], label [[WHILE_COND_I]]
803 ; CHECK: while.end.i:
804 ; CHECK-NEXT: [[BOOL:%.*]] = icmp eq ptr [[A_PN_I]], [[VAL1]]
805 ; CHECK-NEXT: ret i1 [[BOOL]]
808 %test = getelementptr inbounds i8, ptr %val1, i64 2
809 br label %while.cond.i
812 %a.pn.i = phi ptr [ %test.0.i, %while.cond.i ], [ %test, %entry ]
813 %test.0.i = getelementptr i8, ptr %a.pn.i, i64 1
814 %0 = load i8, ptr %test.0.i, align 2
815 %cmp3.not.i = icmp eq i8 %0, 0
816 br i1 %cmp3.not.i, label %while.end.i, label %while.cond.i
819 %sub.ptr.lhs.cast.i = ptrtoint ptr %test.0.i to i64
820 %test.1.i = getelementptr i8, ptr %val1, i64 1
821 %sub.ptr.rhs.cast.i = ptrtoint ptr %test.1.i to i64
822 %sub.ptr.sub.i = sub i64 %sub.ptr.lhs.cast.i, %sub.ptr.rhs.cast.i
823 %bool = icmp eq i64 %sub.ptr.sub.i, 0
827 ;Test where Start and Step are non-inbound.
828 define i1 @recursiveGEP_withPtrSub_noninboundStartAndStep(ptr %val1) {
829 ; CHECK-LABEL: @recursiveGEP_withPtrSub_noninboundStartAndStep(
831 ; CHECK-NEXT: [[TEST:%.*]] = getelementptr i8, ptr [[VAL1:%.*]], i64 1
832 ; CHECK-NEXT: br label [[WHILE_COND_I:%.*]]
833 ; CHECK: while.cond.i:
834 ; CHECK-NEXT: [[A_PN_I:%.*]] = phi ptr [ [[TEST_0_I:%.*]], [[WHILE_COND_I]] ], [ [[TEST]], [[ENTRY:%.*]] ]
835 ; CHECK-NEXT: [[TEST_0_I]] = getelementptr i8, ptr [[A_PN_I]], i64 1
836 ; CHECK-NEXT: [[TMP0:%.*]] = load i8, ptr [[TEST_0_I]], align 2
837 ; CHECK-NEXT: [[CMP3_NOT_I:%.*]] = icmp eq i8 [[TMP0]], 0
838 ; CHECK-NEXT: br i1 [[CMP3_NOT_I]], label [[WHILE_END_I:%.*]], label [[WHILE_COND_I]]
839 ; CHECK: while.end.i:
840 ; CHECK-NEXT: [[BOOL:%.*]] = icmp eq ptr [[TEST_0_I]], [[VAL1]]
841 ; CHECK-NEXT: ret i1 [[BOOL]]
844 %test = getelementptr i8, ptr %val1, i64 1
845 br label %while.cond.i
848 %a.pn.i = phi ptr [ %test.0.i, %while.cond.i ], [ %test, %entry ]
849 %test.0.i = getelementptr i8, ptr %a.pn.i, i64 1
850 %0 = load i8, ptr %test.0.i, align 2
851 %cmp3.not.i = icmp eq i8 %0, 0
852 br i1 %cmp3.not.i, label %while.end.i, label %while.cond.i
855 %sub.ptr.lhs.cast.i = ptrtoint ptr %test.0.i to i64
856 %sub.ptr.rhs.cast.i = ptrtoint ptr %val1 to i64
857 %sub.ptr.sub.i = sub i64 %sub.ptr.lhs.cast.i, %sub.ptr.rhs.cast.i
858 %bool = icmp eq i64 %sub.ptr.sub.i, 0
862 ;Test where Start and GEP B are non-inbounds pointer with same definition.
863 define i1 @recursiveGEP_withPtrSub_noninboundSameDefStartAndB(ptr %val1) {
864 ; CHECK-LABEL: @recursiveGEP_withPtrSub_noninboundSameDefStartAndB(
866 ; CHECK-NEXT: [[TEST:%.*]] = getelementptr i8, ptr [[VAL1:%.*]], i64 1
867 ; CHECK-NEXT: br label [[WHILE_COND_I:%.*]]
868 ; CHECK: while.cond.i:
869 ; CHECK-NEXT: [[A_PN_I:%.*]] = phi ptr [ [[TEST_0_I:%.*]], [[WHILE_COND_I]] ], [ [[TEST]], [[ENTRY:%.*]] ]
870 ; CHECK-NEXT: [[TEST_0_I]] = getelementptr inbounds i8, ptr [[A_PN_I]], i64 1
871 ; CHECK-NEXT: [[TMP0:%.*]] = load i8, ptr [[TEST_0_I]], align 2
872 ; CHECK-NEXT: [[CMP3_NOT_I:%.*]] = icmp eq i8 [[TMP0]], 0
873 ; CHECK-NEXT: br i1 [[CMP3_NOT_I]], label [[WHILE_END_I:%.*]], label [[WHILE_COND_I]]
874 ; CHECK: while.end.i:
875 ; CHECK-NEXT: [[BOOL:%.*]] = icmp eq ptr [[A_PN_I]], [[VAL1]]
876 ; CHECK-NEXT: ret i1 [[BOOL]]
879 %test = getelementptr i8, ptr %val1, i64 1
880 br label %while.cond.i
883 %a.pn.i = phi ptr [ %test.0.i, %while.cond.i ], [ %test, %entry ]
884 %test.0.i = getelementptr inbounds i8, ptr %a.pn.i, i64 1
885 %0 = load i8, ptr %test.0.i, align 2
886 %cmp3.not.i = icmp eq i8 %0, 0
887 br i1 %cmp3.not.i, label %while.end.i, label %while.cond.i
890 %sub.ptr.lhs.cast.i = ptrtoint ptr %test.0.i to i64
891 %test2 = getelementptr i8, ptr %val1, i64 1
892 %sub.ptr.rhs.cast.i = ptrtoint ptr %test2 to i64
893 %sub.ptr.sub.i = sub i64 %sub.ptr.lhs.cast.i, %sub.ptr.rhs.cast.i
894 %bool = icmp eq i64 %sub.ptr.sub.i, 0
898 ;Test where Start and GEP B are non-inbounds and exactly same pointers.
899 define i1 @recursiveGEP_withPtrSub_noninboundSameStartAndB(ptr %val1) {
900 ; CHECK-LABEL: @recursiveGEP_withPtrSub_noninboundSameStartAndB(
902 ; CHECK-NEXT: [[TEST:%.*]] = getelementptr i8, ptr [[VAL1:%.*]], i64 1
903 ; CHECK-NEXT: br label [[WHILE_COND_I:%.*]]
904 ; CHECK: while.cond.i:
905 ; CHECK-NEXT: [[A_PN_I:%.*]] = phi ptr [ [[TEST_0_I:%.*]], [[WHILE_COND_I]] ], [ [[TEST]], [[ENTRY:%.*]] ]
906 ; CHECK-NEXT: [[TEST_0_I]] = getelementptr inbounds i8, ptr [[A_PN_I]], i64 1
907 ; CHECK-NEXT: [[TMP0:%.*]] = load i8, ptr [[TEST_0_I]], align 2
908 ; CHECK-NEXT: [[CMP3_NOT_I:%.*]] = icmp eq i8 [[TMP0]], 0
909 ; CHECK-NEXT: br i1 [[CMP3_NOT_I]], label [[WHILE_END_I:%.*]], label [[WHILE_COND_I]]
910 ; CHECK: while.end.i:
911 ; CHECK-NEXT: ret i1 false
914 %test = getelementptr i8, ptr %val1, i64 1
915 br label %while.cond.i
918 %a.pn.i = phi ptr [ %test.0.i, %while.cond.i ], [ %test, %entry ]
919 %test.0.i = getelementptr inbounds i8, ptr %a.pn.i, i64 1
920 %0 = load i8, ptr %test.0.i, align 2
921 %cmp3.not.i = icmp eq i8 %0, 0
922 br i1 %cmp3.not.i, label %while.end.i, label %while.cond.i
925 %sub.ptr.lhs.cast.i = ptrtoint ptr %test.0.i to i64
926 %sub.ptr.rhs.cast.i = ptrtoint ptr %test to i64
927 %sub.ptr.sub.i = sub i64 %sub.ptr.lhs.cast.i, %sub.ptr.rhs.cast.i
928 %bool = icmp eq i64 %sub.ptr.sub.i, 0
932 define i1 @recursiveGEP_withPtrSub_scalableGEP(ptr %val1) {
933 ; CHECK-LABEL: @recursiveGEP_withPtrSub_scalableGEP(
935 ; CHECK-NEXT: br label [[WHILE_COND_I:%.*]]
936 ; CHECK: while.cond.i:
937 ; CHECK-NEXT: [[A_PN_I:%.*]] = phi ptr [ [[TEST_0_I:%.*]], [[WHILE_COND_I]] ], [ [[VAL1:%.*]], [[ENTRY:%.*]] ]
938 ; CHECK-NEXT: [[TMP0:%.*]] = call i64 @llvm.vscale.i64()
939 ; CHECK-NEXT: [[TMP1:%.*]] = shl i64 [[TMP0]], 4
940 ; CHECK-NEXT: [[TEST_0_I]] = getelementptr i8, ptr [[A_PN_I]], i64 [[TMP1]]
941 ; CHECK-NEXT: [[TMP2:%.*]] = load i8, ptr [[TEST_0_I]], align 1
942 ; CHECK-NEXT: [[CMP3_NOT_I:%.*]] = icmp eq i8 [[TMP2]], 0
943 ; CHECK-NEXT: br i1 [[CMP3_NOT_I]], label [[WHILE_END_I:%.*]], label [[WHILE_COND_I]]
944 ; CHECK: while.end.i:
945 ; CHECK-NEXT: [[BOOL:%.*]] = icmp eq ptr [[TEST_0_I]], [[VAL1]]
946 ; CHECK-NEXT: ret i1 [[BOOL]]
949 br label %while.cond.i
952 %a.pn.i = phi ptr [ %test.0.i, %while.cond.i ], [ %val1, %entry ]
953 %test.0.i = getelementptr <vscale x 16 x i8>, ptr %a.pn.i, i64 1
954 %0 = load i8, ptr %test.0.i, align 1
955 %cmp3.not.i = icmp eq i8 %0, 0
956 br i1 %cmp3.not.i, label %while.end.i, label %while.cond.i
959 %sub.ptr.lhs.cast.i = ptrtoint ptr %test.0.i to i64
960 %sub.ptr.rhs.cast.i = ptrtoint ptr %val1 to i64
961 %sub.ptr.sub.i = sub i64 %sub.ptr.lhs.cast.i, %sub.ptr.rhs.cast.i
962 %bool = icmp eq i64 %sub.ptr.sub.i, 0
966 define i1 @recursiveGEP_withPtrSub_scalableGEP_inbounds(ptr %val1) {
967 ; CHECK-LABEL: @recursiveGEP_withPtrSub_scalableGEP_inbounds(
969 ; CHECK-NEXT: br label [[WHILE_COND_I:%.*]]
970 ; CHECK: while.cond.i:
971 ; CHECK-NEXT: [[A_PN_I:%.*]] = phi ptr [ [[TEST_0_I:%.*]], [[WHILE_COND_I]] ], [ [[VAL1:%.*]], [[ENTRY:%.*]] ]
972 ; CHECK-NEXT: [[TMP0:%.*]] = call i64 @llvm.vscale.i64()
973 ; CHECK-NEXT: [[TMP1:%.*]] = shl i64 [[TMP0]], 4
974 ; CHECK-NEXT: [[TEST_0_I]] = getelementptr inbounds i8, ptr [[A_PN_I]], i64 [[TMP1]]
975 ; CHECK-NEXT: [[TMP2:%.*]] = load i8, ptr [[TEST_0_I]], align 1
976 ; CHECK-NEXT: [[CMP3_NOT_I:%.*]] = icmp eq i8 [[TMP2]], 0
977 ; CHECK-NEXT: br i1 [[CMP3_NOT_I]], label [[WHILE_END_I:%.*]], label [[WHILE_COND_I]]
978 ; CHECK: while.end.i:
979 ; CHECK-NEXT: [[BOOL:%.*]] = icmp eq ptr [[TEST_0_I]], [[VAL1]]
980 ; CHECK-NEXT: ret i1 [[BOOL]]
983 br label %while.cond.i
986 %a.pn.i = phi ptr [ %test.0.i, %while.cond.i ], [ %val1, %entry ]
987 %test.0.i = getelementptr inbounds <vscale x 16 x i8>, ptr %a.pn.i, i64 1
988 %0 = load i8, ptr %test.0.i, align 1
989 %cmp3.not.i = icmp eq i8 %0, 0
990 br i1 %cmp3.not.i, label %while.end.i, label %while.cond.i
993 %sub.ptr.lhs.cast.i = ptrtoint ptr %test.0.i to i64
994 %sub.ptr.rhs.cast.i = ptrtoint ptr %val1 to i64
995 %sub.ptr.sub.i = sub i64 %sub.ptr.lhs.cast.i, %sub.ptr.rhs.cast.i
996 %bool = icmp eq i64 %sub.ptr.sub.i, 0
1000 ; Test cmp(or), where one of argument to OR is a SUB of ptr2int with a recursive GEP.
1001 define i1 @recursiveGEP_orcmp(ptr %val1, i64 %val2) {
1002 ; CHECK-LABEL: @recursiveGEP_orcmp(
1003 ; CHECK-NEXT: entry:
1004 ; CHECK-NEXT: br label [[WHILE_COND_I:%.*]]
1005 ; CHECK: while.cond.i:
1006 ; CHECK-NEXT: [[A_PN_I:%.*]] = phi ptr [ [[TEST_0_I:%.*]], [[WHILE_COND_I]] ], [ [[VAL1:%.*]], [[ENTRY:%.*]] ]
1007 ; CHECK-NEXT: [[TEST_0_I]] = getelementptr inbounds i8, ptr [[A_PN_I]], i64 1
1008 ; CHECK-NEXT: [[TMP0:%.*]] = load i8, ptr [[TEST_0_I]], align 2
1009 ; CHECK-NEXT: [[CMP3_NOT_I:%.*]] = icmp eq i8 [[TMP0]], 0
1010 ; CHECK-NEXT: br i1 [[CMP3_NOT_I]], label [[WHILE_END_I:%.*]], label [[WHILE_COND_I]]
1011 ; CHECK: while.end.i:
1012 ; CHECK-NEXT: ret i1 false
1015 br label %while.cond.i
1018 %a.pn.i = phi ptr [ %test.0.i, %while.cond.i ], [ %val1, %entry ]
1019 %test.0.i = getelementptr inbounds i8, ptr %a.pn.i, i64 1
1020 %0 = load i8, ptr %test.0.i, align 2
1021 %cmp3.not.i = icmp eq i8 %0, 0
1022 br i1 %cmp3.not.i, label %while.end.i, label %while.cond.i
1025 %sub.ptr.lhs.cast.i = ptrtoint ptr %test.0.i to i64
1026 %sub.ptr.rhs.cast.i = ptrtoint ptr %val1 to i64
1027 %sub.ptr.sub.i = sub i64 %sub.ptr.lhs.cast.i, %sub.ptr.rhs.cast.i
1028 %orval = or i64 %sub.ptr.sub.i, %val2
1029 %bool = icmp eq i64 %orval, 0
1033 define i1 @recursiveGEP_orcmp_orOperandsCommuted(ptr %val1, i64 %val2) {
1034 ; CHECK-LABEL: @recursiveGEP_orcmp_orOperandsCommuted(
1035 ; CHECK-NEXT: entry:
1036 ; CHECK-NEXT: br label [[WHILE_COND_I:%.*]]
1037 ; CHECK: while.cond.i:
1038 ; CHECK-NEXT: [[A_PN_I:%.*]] = phi ptr [ [[TEST_0_I:%.*]], [[WHILE_COND_I]] ], [ [[VAL1:%.*]], [[ENTRY:%.*]] ]
1039 ; CHECK-NEXT: [[TEST_0_I]] = getelementptr inbounds i8, ptr [[A_PN_I]], i64 1
1040 ; CHECK-NEXT: [[TMP0:%.*]] = load i8, ptr [[TEST_0_I]], align 2
1041 ; CHECK-NEXT: [[CMP3_NOT_I:%.*]] = icmp eq i8 [[TMP0]], 0
1042 ; CHECK-NEXT: br i1 [[CMP3_NOT_I]], label [[WHILE_END_I:%.*]], label [[WHILE_COND_I]]
1043 ; CHECK: while.end.i:
1044 ; CHECK-NEXT: ret i1 false
1047 br label %while.cond.i
1050 %a.pn.i = phi ptr [ %test.0.i, %while.cond.i ], [ %val1, %entry ]
1051 %test.0.i = getelementptr inbounds i8, ptr %a.pn.i, i64 1
1052 %0 = load i8, ptr %test.0.i, align 2
1053 %cmp3.not.i = icmp eq i8 %0, 0
1054 br i1 %cmp3.not.i, label %while.end.i, label %while.cond.i
1057 %sub.ptr.lhs.cast.i = ptrtoint ptr %test.0.i to i64
1058 %sub.ptr.rhs.cast.i = ptrtoint ptr %val1 to i64
1059 %sub.ptr.sub.i = sub i64 %sub.ptr.lhs.cast.i, %sub.ptr.rhs.cast.i
1060 %orval = or i64 %val2, %sub.ptr.sub.i
1061 %bool = icmp eq i64 %orval, 0
1065 ; Test one of the argument to SUB is a ptr2int of a recursive GEP, with multiple use of SUB.
1066 define i1 @recursiveGEP_orcmpMultiUse(ptr %val1, i64 %val2, ptr %dv1, ptr %dv2) {
1067 ; CHECK-LABEL: @recursiveGEP_orcmpMultiUse(
1068 ; CHECK-NEXT: entry:
1069 ; CHECK-NEXT: br label [[WHILE_COND_I:%.*]]
1070 ; CHECK: while.cond.i:
1071 ; CHECK-NEXT: [[A_PN_I:%.*]] = phi ptr [ [[TEST_0_I:%.*]], [[WHILE_COND_I]] ], [ [[VAL1:%.*]], [[ENTRY:%.*]] ]
1072 ; CHECK-NEXT: [[TEST_0_I]] = getelementptr inbounds i8, ptr [[A_PN_I]], i64 1
1073 ; CHECK-NEXT: [[TMP0:%.*]] = load i8, ptr [[TEST_0_I]], align 2
1074 ; CHECK-NEXT: [[CMP3_NOT_I:%.*]] = icmp eq i8 [[TMP0]], 0
1075 ; CHECK-NEXT: br i1 [[CMP3_NOT_I]], label [[WHILE_END_I:%.*]], label [[WHILE_COND_I]]
1076 ; CHECK: while.end.i:
1077 ; CHECK-NEXT: br i1 false, label [[IF_THEN:%.*]], label [[IF_END4:%.*]]
1079 ; CHECK-NEXT: br label [[CLEANUP:%.*]]
1081 ; CHECK-NEXT: br label [[CLEANUP]]
1083 ; CHECK-NEXT: ret i1 true
1086 br label %while.cond.i
1089 %a.pn.i = phi ptr [ %test.0.i, %while.cond.i ], [ %val1, %entry ]
1090 %test.0.i = getelementptr inbounds i8, ptr %a.pn.i, i64 1
1091 %0 = load i8, ptr %test.0.i, align 2
1092 %cmp3.not.i = icmp eq i8 %0, 0
1093 br i1 %cmp3.not.i, label %while.end.i, label %while.cond.i
1096 %sub.ptr.lhs.cast.i = ptrtoint ptr %test.0.i to i64
1097 %sub.ptr.rhs.cast.i = ptrtoint ptr %val1 to i64
1098 %sub.ptr.sub.i = sub i64 %sub.ptr.lhs.cast.i, %sub.ptr.rhs.cast.i
1099 %orval = or i64 %sub.ptr.sub.i, %val2
1100 %or.cond = icmp eq i64 %orval, 0
1101 br i1 %or.cond, label %if.then, label %if.end4
1104 %cmp = icmp eq ptr %dv1, %dv2
1108 %tobool = icmp ne i64 %sub.ptr.sub.i, 0
1112 %retval.0 = phi i1 [ %cmp, %if.then ], [ %tobool, %if.end4 ]