1; RUN: opt < %s -loop-reduce -S -mtriple=x86_64-unknown-unknown | 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 ] 18 %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 28; CHECK: phi double [ -3.900000e+01, %entry ] 29; 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 38 %inc = add nsw i32 %i.01, 1 39 br i1 undef, label %loop, label %for.end 40 41for.end: 42 unreachable 43} 44