Home | History | Annotate | Download | only in ScalarEvolution
      1 ; RUN: opt < %s -analyze -scalar-evolution \
      2 ; RUN:   -scalar-evolution-max-iterations=0 | FileCheck %s
      3 
      4 ; PR1101
      5 
      6 @A = weak global [1000 x i32] zeroinitializer, align 32         
      7 
      8 define void @test1(i32 %N) {
      9 entry:
     10         %"alloca point" = bitcast i32 0 to i32           ; <i32> [#uses=0]
     11         br label %bb3
     12 
     13 bb:             ; preds = %bb3
     14         %tmp = getelementptr [1000 x i32]* @A, i32 0, i32 %i.0          ; <i32*> [#uses=1]
     15         store i32 123, i32* %tmp
     16         %tmp2 = add i32 %i.0, 1         ; <i32> [#uses=1]
     17         br label %bb3
     18 
     19 bb3:            ; preds = %bb, %entry
     20         %i.0 = phi i32 [ 2, %entry ], [ %tmp2, %bb ]            ; <i32> [#uses=3]
     21         %SQ = mul i32 %i.0, %i.0
     22         %tmp4 = mul i32 %i.0, 2
     23         %tmp5 = sub i32 %SQ, %tmp4
     24         %tmp3 = icmp sle i32 %tmp5, 9999          ; <i1> [#uses=1]
     25         br i1 %tmp3, label %bb, label %bb5
     26 
     27 bb5:            ; preds = %bb3
     28         br label %return
     29 
     30 return:         ; preds = %bb5
     31         ret void
     32 }
     33 ; CHECK: Determining loop execution counts for: @test1
     34 ; CHECK-NEXT: backedge-taken count is 100
     35 
     36 
     37 ; PR10383
     38 ; These next two used to crash.
     39 
     40 define void @test2(i1 %cmp, i64 %n) {
     41 entry:
     42   br label %for.body1
     43 
     44 for.body1:
     45   %a0.08 = phi i64 [ 0, %entry ], [ %inc512, %for.body1 ]
     46   %inc512 = add i64 %a0.08, 1
     47   br i1 %cmp, label %preheader, label %for.body1
     48 
     49 preheader:
     50   br label %for.body2
     51 
     52 for.body2:
     53   %indvar = phi i64 [ 0, %preheader ], [ %indvar.next, %for.body2 ]
     54   %tmp111 = add i64 %n, %indvar
     55   %tmp114 = mul i64 %a0.08, %indvar
     56   %mul542 = mul i64 %tmp114, %tmp111
     57   %indvar.next = add i64 %indvar, 1
     58   br i1 undef, label %end, label %for.body2
     59 
     60 end:
     61   ret void
     62 }
     63 ; CHECK: Determining loop execution counts for: @test2
     64 
     65 define i32 @test3() {
     66 if.then466:
     67   br i1 undef, label %for.cond539.preheader, label %for.inc479
     68 
     69 for.inc479:
     70   %a2.07 = phi i32 [ %add495, %for.inc479 ], [ 0, %if.then466 ]
     71   %j.36 = phi i32 [ %inc497, %for.inc479 ], [ undef, %if.then466 ]
     72   %mul484 = mul nsw i32 %j.36, %j.36
     73   %mul491 = mul i32 %j.36, %j.36
     74   %mul493 = mul i32 %mul491, %mul484
     75   %add495 = add nsw i32 %mul493, %a2.07
     76   %inc497 = add nsw i32 %j.36, 1
     77   br i1 undef, label %for.cond539.preheader, label %for.inc479
     78 
     79 for.cond539.preheader:
     80   unreachable
     81 }
     82 ; CHECK: Determining loop execution counts for: @test3
     83