blob: 5d9ed64ef4223372012c93fdbd7ae1df7ce81a03 [file] [log] [blame]
Andrew Trick37eb38d2011-07-21 00:40:04 +00001; RUN: opt < %s -loop-reduce -S | FileCheck %s
2;
3; Test LSR's OptimizeShadowIV. Handle a floating-point IV with a
4; nonzero initial value.
5; rdar://9786536
6
7; First, make sure LSR doesn't crash on an empty IVUsers list.
8; CHECK: @dummyIV
9; CHECK-NOT: phi
10; CHECK-NOT: sitofp
11; CHECK: br
12define void @dummyIV() nounwind {
13entry:
14 br label %loop
15
16loop:
17 %i.01 = phi i32 [ -39, %entry ], [ %inc, %loop ]
Andrew Trickc2c988e2011-07-21 01:05:01 +000018 %conv = sitofp i32 %i.01 to double
19 %inc = add nsw i32 %i.01, 1
20 br i1 undef, label %loop, label %for.end
21
22for.end:
23 unreachable
24}
25
26; Now check that the computed double constant is correct.
27; CHECK: @doubleIV
Andrew Trickc205a092011-07-21 01:45:54 +000028; CHECK: phi double [ -3.900000e+01, %entry ]
Andrew Trickc2c988e2011-07-21 01:05:01 +000029; CHECK: br
30define void @doubleIV() nounwind {
31entry:
32 br label %loop
33
34loop:
35 %i.01 = phi i32 [ -39, %entry ], [ %inc, %loop ]
36 %conv = sitofp i32 %i.01 to double
37 %div = fdiv double %conv, 4.000000e+01
Andrew Trick37eb38d2011-07-21 00:40:04 +000038 %inc = add nsw i32 %i.01, 1
39 br i1 undef, label %loop, label %for.end
40
41for.end:
42 unreachable
43}