Home | History | Annotate | Download | only in X86
      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 ; Provide legal integer types.
      8 target datalayout = "n8:16:32:64"
      9 
     10 
     11 ; First, make sure LSR doesn't crash on an empty IVUsers list.
     12 ; CHECK-LABEL: @dummyIV(
     13 ; CHECK-NOT: phi
     14 ; CHECK-NOT: sitofp
     15 ; CHECK: br
     16 define void @dummyIV() nounwind {
     17 entry:
     18   br label %loop
     19 
     20 loop:
     21   %i.01 = phi i32 [ -39, %entry ], [ %inc, %loop ]
     22   %conv = sitofp i32 %i.01 to double
     23   %inc = add nsw i32 %i.01, 1
     24   br i1 undef, label %loop, label %for.end
     25 
     26 for.end:
     27   unreachable
     28 }
     29 
     30 ; Now check that the computed double constant is correct.
     31 ; CHECK-LABEL: @doubleIV(
     32 ; CHECK: phi double [ -3.900000e+01, %entry ]
     33 ; CHECK: br
     34 define void @doubleIV() nounwind {
     35 entry:
     36   br label %loop
     37 
     38 loop:
     39   %i.01 = phi i32 [ -39, %entry ], [ %inc, %loop ]
     40   %conv = sitofp i32 %i.01 to double
     41   %div = fdiv double %conv, 4.000000e+01
     42   %inc = add nsw i32 %i.01, 1
     43   br i1 undef, label %loop, label %for.end
     44 
     45 for.end:
     46   unreachable
     47 }
     48