1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -indvars -S < %s | FileCheck %s
3 ; RUN: opt -passes=indvars -S < %s | FileCheck %s
7 define i32 @test_01(i32* %p, i32* %s) {
8 ; CHECK-LABEL: @test_01(
10 ; CHECK-NEXT: [[START:%.*]] = load i32, i32* [[P:%.*]], align 4, !range [[RNG0:![0-9]+]]
11 ; CHECK-NEXT: [[END:%.*]] = load i32, i32* [[S:%.*]], align 4, !range [[RNG0]]
12 ; CHECK-NEXT: br label [[LOOP:%.*]]
14 ; CHECK-NEXT: [[IV:%.*]] = phi i32 [ [[START]], [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[BACKEDGE:%.*]] ]
15 ; CHECK-NEXT: [[C1:%.*]] = icmp slt i32 [[IV]], [[END]]
16 ; CHECK-NEXT: br i1 [[C1]], label [[GUARDED:%.*]], label [[SIDE_EXIT:%.*]]
18 ; CHECK-NEXT: br i1 true, label [[BACKEDGE]], label [[SIDE_EXIT]]
20 ; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i32 [[IV]], 1
21 ; CHECK-NEXT: [[LOOP_COND:%.*]] = call i1 @cond()
22 ; CHECK-NEXT: br i1 [[LOOP_COND]], label [[LOOP]], label [[EXIT:%.*]]
24 ; CHECK-NEXT: ret i32 1
26 ; CHECK-NEXT: ret i32 0
29 %start = load i32, i32* %p, !range !0
30 %end = load i32, i32* %s, !range !0
34 %iv = phi i32 [%start, %entry], [%iv.next, %backedge]
35 %c1 = icmp slt i32 %iv, %end
36 br i1 %c1, label %guarded, label %side_exit
39 %c2 = icmp ult i32 %iv, %end
40 br i1 %c2, label %backedge, label %side_exit
43 %iv.next = add nuw nsw i32 %iv, 1
44 %loop.cond = call i1 @cond()
45 br i1 %loop.cond, label %loop, label %exit
54 define i32 @test_02(i32* %p, i32* %s) {
55 ; CHECK-LABEL: @test_02(
57 ; CHECK-NEXT: [[START:%.*]] = load i32, i32* [[P:%.*]], align 4, !range [[RNG0]]
58 ; CHECK-NEXT: [[END:%.*]] = load i32, i32* [[S:%.*]], align 4, !range [[RNG0]]
59 ; CHECK-NEXT: br label [[LOOP:%.*]]
61 ; CHECK-NEXT: [[IV:%.*]] = phi i32 [ [[START]], [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[BACKEDGE:%.*]] ]
62 ; CHECK-NEXT: [[C1:%.*]] = icmp ult i32 [[IV]], [[END]]
63 ; CHECK-NEXT: br i1 [[C1]], label [[GUARDED:%.*]], label [[SIDE_EXIT:%.*]]
65 ; CHECK-NEXT: br i1 true, label [[BACKEDGE]], label [[SIDE_EXIT]]
67 ; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i32 [[IV]], 1
68 ; CHECK-NEXT: [[LOOP_COND:%.*]] = call i1 @cond()
69 ; CHECK-NEXT: br i1 [[LOOP_COND]], label [[LOOP]], label [[EXIT:%.*]]
71 ; CHECK-NEXT: ret i32 1
73 ; CHECK-NEXT: ret i32 0
76 %start = load i32, i32* %p, !range !0
77 %end = load i32, i32* %s, !range !0
81 %iv = phi i32 [%start, %entry], [%iv.next, %backedge]
82 %c1 = icmp ult i32 %iv, %end
83 br i1 %c1, label %guarded, label %side_exit
86 %c2 = icmp slt i32 %iv, %end
87 br i1 %c2, label %backedge, label %side_exit
90 %iv.next = add nuw nsw i32 %iv, 1
91 %loop.cond = call i1 @cond()
92 br i1 %loop.cond, label %loop, label %exit
101 !0 = !{i32 -1000, i32 0}