1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -newgvn -S | FileCheck %s
4 define void @sort(i64 %.16) {
7 ; CHECK-NEXT: [[TMP0:%.*]] = extractvalue { i64, i1 } undef, 0
8 ; CHECK-NEXT: [[TMP1:%.*]] = lshr i64 [[TMP0]], 2
9 ; CHECK-NEXT: br i1 undef, label [[DIVZEROFAIL2_I:%.*]], label [[WHILEBODY_LR_PH:%.*]]
10 ; CHECK: DivZeroFail2.i:
11 ; CHECK-NEXT: unreachable
12 ; CHECK: WhileBody.lr.ph:
13 ; CHECK-NEXT: [[TMP2:%.*]] = udiv i64 [[DOT16:%.*]], [[TMP1]]
14 ; CHECK-NEXT: br label [[WHILEBODY:%.*]]
16 ; CHECK-NEXT: [[ITERATOR:%.*]] = phi i64 [ 0, [[WHILEBODY_LR_PH]] ], [ [[TMP6:%.*]], [[BOUNDSCHECKOK276:%.*]] ]
17 ; CHECK-NEXT: [[TMP3:%.*]] = tail call { i64, i1 } @llvm.uadd.with.overflow.i64(i64 [[ITERATOR]], i64 [[TMP2]])
18 ; CHECK-NEXT: [[TMP4:%.*]] = extractvalue { i64, i1 } [[TMP3]], 0
19 ; CHECK-NEXT: [[TMP5:%.*]] = tail call { i64, i1 } @llvm.uadd.with.overflow.i64(i64 [[TMP4]], i64 1)
20 ; CHECK-NEXT: [[TMP6]] = extractvalue { i64, i1 } [[TMP5]], 0
21 ; CHECK-NEXT: br i1 false, label [[BOUNDSCHECKFAIL275:%.*]], label [[BOUNDSCHECKOK276]]
23 ; CHECK-NEXT: ret void
24 ; CHECK: BoundsCheckFail275:
25 ; CHECK-NEXT: unreachable
26 ; CHECK: BoundsCheckOk276:
27 ; CHECK-NEXT: [[TMP7:%.*]] = icmp ult i64 [[TMP6]], [[DOT16]]
28 ; CHECK-NEXT: br i1 [[TMP7]], label [[WHILEBODY]], label [[WHILEEND:%.*]]
31 %0 = extractvalue { i64, i1 } undef, 0
33 br i1 undef, label %DivZeroFail2.i, label %WhileBody.lr.ph
35 DivZeroFail2.i: ; preds = %Entry
38 WhileBody.lr.ph: ; preds = %Entry
39 %2 = udiv i64 %.16, %1
42 WhileBody: ; preds = %BoundsCheckOk276, %WhileBody.lr.ph
43 %iterator = phi i64 [ 0, %WhileBody.lr.ph ], [ %6, %BoundsCheckOk276 ]
44 %3 = tail call { i64, i1 } @llvm.uadd.with.overflow.i64(i64 %iterator, i64 %2)
45 %4 = extractvalue { i64, i1 } %3, 0
46 %5 = tail call { i64, i1 } @llvm.uadd.with.overflow.i64(i64 %4, i64 1)
47 %6 = extractvalue { i64, i1 } %5, 0
48 %7 = icmp ugt i64 %iterator, %.16
49 br i1 %7, label %BoundsCheckFail275, label %BoundsCheckOk276
51 WhileEnd: ; preds = %BoundsCheckOk276
54 BoundsCheckFail275: ; preds = %WhileBody
57 BoundsCheckOk276: ; preds = %WhileBody
58 %8 = icmp ult i64 %6, %.16
59 br i1 %8, label %WhileBody, label %WhileEnd
62 declare { i64, i1 } @llvm.uadd.with.overflow.i64(i64, i64)