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-LABEL: @dummyIV( 9 ; CHECK-NOT: phi 10 ; CHECK-NOT: sitofp 11 ; CHECK: br 12 define void @dummyIV() nounwind { 13 entry: 14 br label %loop 15 16 loop: 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 22 for.end: 23 unreachable 24 } 25 26 ; Now check that the computed double constant is correct. 27 ; CHECK-LABEL: @doubleIV( 28 ; CHECK: phi double [ -3.900000e+01, %entry ] 29 ; CHECK: br 30 define void @doubleIV() nounwind { 31 entry: 32 br label %loop 33 34 loop: 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 41 for.end: 42 unreachable 43 } 44