Dan Gohman | 934af9c | 2009-10-23 17:10:01 +0000 | [diff] [blame^] | 1 | ; RUN: opt < %s -loop-deletion -S | FileCheck %s |
| 2 | |
| 3 | ; ScalarEvolution can prove the loop iteration is finite, even though |
| 4 | ; it can't represent the exact trip count as an expression. That's |
| 5 | ; good enough to let the loop be deleted. |
| 6 | |
| 7 | ; CHECK: entry: |
| 8 | ; CHECK-NEXT: br label %return |
| 9 | |
| 10 | ; CHECK: return: |
| 11 | ; CHECK-NEXT: ret void |
| 12 | |
| 13 | define void @foo(i64 %n, i64 %m) nounwind { |
| 14 | entry: |
| 15 | br label %bb |
| 16 | |
| 17 | bb: |
| 18 | %x.0 = phi i64 [ 0, %entry ], [ %t0, %bb ] |
| 19 | %t0 = add i64 %x.0, 1 |
| 20 | %t1 = icmp slt i64 %x.0, %n |
| 21 | %t3 = icmp sgt i64 %x.0, %m |
| 22 | %t4 = and i1 %t1, %t3 |
| 23 | br i1 %t4, label %bb, label %return |
| 24 | |
| 25 | return: |
| 26 | ret void |
| 27 | } |