Dan Gohman | 8a977e2 | 2010-01-26 19:25:59 +0000 | [diff] [blame] | 1 | ; RUN: opt < %s -analyze -scalar-evolution \ |
Nick Lewycky | fa151a7 | 2011-09-06 05:05:14 +0000 | [diff] [blame^] | 2 | ; RUN: -scalar-evolution-max-iterations=0 | FileCheck %s |
| 3 | |
Zhou Sheng | fc24a72 | 2007-04-26 16:44:48 +0000 | [diff] [blame] | 4 | ; PR1101 |
| 5 | |
| 6 | @A = weak global [1000 x i32] zeroinitializer, align 32 |
| 7 | |
Nick Lewycky | fa151a7 | 2011-09-06 05:05:14 +0000 | [diff] [blame^] | 8 | define void @test1(i32 %N) { |
Zhou Sheng | fc24a72 | 2007-04-26 16:44:48 +0000 | [diff] [blame] | 9 | entry: |
Chris Lattner | 7a1b9bd | 2011-06-17 06:36:20 +0000 | [diff] [blame] | 10 | %"alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0] |
Zhou Sheng | fc24a72 | 2007-04-26 16:44:48 +0000 | [diff] [blame] | 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 | } |
Nick Lewycky | fa151a7 | 2011-09-06 05:05:14 +0000 | [diff] [blame^] | 33 | ; CHECK: Determining loop execution counts for: @test1 |
| 34 | ; CHECK-NEXT: backedge-taken count is 100 |
| 35 | |
| 36 | |
| 37 | ; PR10383 |
| 38 | ; This 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 |