Zhaoshi Zheng | e3c9070 | 2017-03-23 18:06:09 +0000 | [diff] [blame] | 1 | ; RUN: opt < %s -analyze -scalar-evolution | FileCheck %s |
| 2 | |
| 3 | ; CHECK: %tmp9 = shl i64 %tmp8, 33 |
| 4 | ; CHECK-NEXT: --> {{.*}} Exits: (-8589934592 + (8589934592 * (zext i32 %arg2 to i64))) |
| 5 | ; CHECK-NEXT: %tmp10 = ashr exact i64 %tmp9, 0 |
| 6 | ; CHECK-NEXT: --> {{.*}} Exits: (-8589934592 + (8589934592 * (zext i32 %arg2 to i64))) |
| 7 | |
| 8 | define void @foo(i32* nocapture %arg, i32 %arg1, i32 %arg2) { |
| 9 | bb: |
| 10 | %tmp = icmp sgt i32 %arg2, 0 |
| 11 | br i1 %tmp, label %bb3, label %bb6 |
| 12 | |
| 13 | bb3: ; preds = %bb |
| 14 | %tmp4 = zext i32 %arg2 to i64 |
| 15 | br label %bb7 |
| 16 | |
| 17 | bb5: ; preds = %bb7 |
| 18 | br label %bb6 |
| 19 | |
| 20 | bb6: ; preds = %bb5, %bb |
| 21 | ret void |
| 22 | |
| 23 | bb7: ; preds = %bb7, %bb3 |
| 24 | %tmp8 = phi i64 [ %tmp18, %bb7 ], [ 0, %bb3 ] |
| 25 | %tmp9 = shl i64 %tmp8, 33 |
| 26 | %tmp10 = ashr exact i64 %tmp9, 0 |
| 27 | %tmp11 = getelementptr inbounds i32, i32* %arg, i64 %tmp10 |
| 28 | %tmp12 = load i32, i32* %tmp11, align 4 |
| 29 | %tmp13 = sub nsw i32 %tmp12, %arg1 |
| 30 | store i32 %tmp13, i32* %tmp11, align 4 |
| 31 | %tmp14 = or i64 %tmp10, 1 |
| 32 | %tmp15 = getelementptr inbounds i32, i32* %arg, i64 %tmp14 |
| 33 | %tmp16 = load i32, i32* %tmp15, align 4 |
| 34 | %tmp17 = mul nsw i32 %tmp16, %arg1 |
| 35 | store i32 %tmp17, i32* %tmp15, align 4 |
| 36 | %tmp18 = add nuw nsw i64 %tmp8, 1 |
| 37 | %tmp19 = icmp eq i64 %tmp18, %tmp4 |
| 38 | br i1 %tmp19, label %bb5, label %bb7 |
| 39 | } |