1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -indvars -S | FileCheck %s
4 define void @test1() nounwind {
7 ; CHECK-NEXT: br label [[BB:%.*]]
9 ; CHECK-NEXT: [[IV_INT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[DOTINT:%.*]], [[BB]] ]
10 ; CHECK-NEXT: [[INDVAR_CONV:%.*]] = sitofp i32 [[IV_INT]] to double
11 ; CHECK-NEXT: [[TMP0:%.*]] = tail call i32 @foo(double [[INDVAR_CONV]]) #0
12 ; CHECK-NEXT: [[DOTINT]] = add nuw nsw i32 [[IV_INT]], 1
13 ; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i32 [[DOTINT]], 10000
14 ; CHECK-NEXT: br i1 [[TMP1]], label [[BB]], label [[RETURN:%.*]]
16 ; CHECK-NEXT: ret void
21 bb: ; preds = %bb, %entry
22 %iv = phi double [ 0.000000e+00, %entry ], [ %1, %bb ]
23 %0 = tail call i32 @foo(double %iv) nounwind
24 %1 = fadd double %iv, 1.000000e+00
25 %2 = fcmp olt double %1, 1.000000e+04
26 br i1 %2, label %bb, label %return
32 declare i32 @foo(double)
34 define void @test2() nounwind {
35 ; CHECK-LABEL: @test2(
37 ; CHECK-NEXT: br label [[BB:%.*]]
39 ; CHECK-NEXT: [[IV_INT:%.*]] = phi i32 [ -10, [[ENTRY:%.*]] ], [ [[DOTINT:%.*]], [[BB]] ]
40 ; CHECK-NEXT: [[INDVAR_CONV:%.*]] = sitofp i32 [[IV_INT]] to double
41 ; CHECK-NEXT: [[TMP0:%.*]] = tail call i32 @foo(double [[INDVAR_CONV]]) #0
42 ; CHECK-NEXT: [[DOTINT]] = add nsw i32 [[IV_INT]], 2
43 ; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i32 [[DOTINT]], -1
44 ; CHECK-NEXT: br i1 [[TMP1]], label [[BB]], label [[RETURN:%.*]]
46 ; CHECK-NEXT: ret void
51 bb: ; preds = %bb, %entry
52 %iv = phi double [ -10.000000e+00, %entry ], [ %1, %bb ]
53 %0 = tail call i32 @foo(double %iv) nounwind
54 %1 = fadd double %iv, 2.000000e+00
55 %2 = fcmp olt double %1, -1.000000e+00
56 br i1 %2, label %bb, label %return
63 define void @test3() nounwind {
64 ; CHECK-LABEL: @test3(
66 ; CHECK-NEXT: br label [[BB:%.*]]
68 ; CHECK-NEXT: [[IV:%.*]] = phi double [ 0.000000e+00, [[ENTRY:%.*]] ], [ [[TMP1:%.*]], [[BB]] ]
69 ; CHECK-NEXT: [[TMP0:%.*]] = tail call i32 @foo(double [[IV]]) #0
70 ; CHECK-NEXT: [[TMP1]] = fadd double [[IV]], 1.000000e+00
71 ; CHECK-NEXT: br i1 false, label [[BB]], label [[RETURN:%.*]]
73 ; CHECK-NEXT: ret void
78 bb: ; preds = %bb, %entry
79 %iv = phi double [ 0.000000e+00, %entry ], [ %1, %bb ]
80 %0 = tail call i32 @foo(double %iv) nounwind
81 %1 = fadd double %iv, 1.000000e+00
82 %2 = fcmp olt double %1, -1.000000e+00
83 br i1 %2, label %bb, label %return
89 define void @test4() nounwind {
90 ; CHECK-LABEL: @test4(
92 ; CHECK-NEXT: br label [[BB:%.*]]
94 ; CHECK-NEXT: [[IV_INT:%.*]] = phi i32 [ 40, [[ENTRY:%.*]] ], [ [[DOTINT:%.*]], [[BB]] ]
95 ; CHECK-NEXT: [[INDVAR_CONV:%.*]] = sitofp i32 [[IV_INT]] to double
96 ; CHECK-NEXT: [[TMP0:%.*]] = tail call i32 @foo(double [[INDVAR_CONV]]) #0
97 ; CHECK-NEXT: [[DOTINT]] = add nsw i32 [[IV_INT]], -1
98 ; CHECK-NEXT: br i1 false, label [[BB]], label [[RETURN:%.*]]
100 ; CHECK-NEXT: ret void
105 bb: ; preds = %bb, %entry
106 %iv = phi double [ 40.000000e+00, %entry ], [ %1, %bb ]
107 %0 = tail call i32 @foo(double %iv) nounwind
108 %1 = fadd double %iv, -1.000000e+00
109 %2 = fcmp olt double %1, 1.000000e+00
110 br i1 %2, label %bb, label %return
117 define void @test5() nounwind {
119 ; CHECK-LABEL: @test5(
120 ; CHECK-NEXT: br label [[TMP1:%.*]]
122 ; CHECK-NEXT: [[DOTINT:%.*]] = phi i32 [ 9, [[TMP0:%.*]] ], [ [[DOTINT1:%.*]], [[TMP1]] ]
123 ; CHECK-NEXT: [[TMP2:%.*]] = tail call i32 @foo(double 0.000000e+00)
124 ; CHECK-NEXT: [[DOTINT1]] = add nsw i32 [[DOTINT]], -1
125 ; CHECK-NEXT: [[TMP3:%.*]] = icmp slt i32 [[DOTINT1]], 0
126 ; CHECK-NEXT: br i1 [[TMP3]], label [[EXIT:%.*]], label [[TMP1]]
128 ; CHECK-NEXT: ret void
133 %2 = phi double [ 9.000000e+00, %0 ], [ %4, %1 ]
134 %3 = tail call i32 @foo(double 0.0)
135 %4 = fadd double %2, -1.000000e+00
136 %5 = fcmp ult double %4, 0.000000e+00
137 br i1 %5, label %exit, label %1