Chris Lattner | 69e067f | 2008-11-27 05:07:53 +0000 | [diff] [blame^] | 1 | ; RUN: llvm-as < %s | opt -jump-threading -mem2reg -simplifycfg | llvm-dis | grep {ret i32 1} |
| 2 | ; rdar://6402033 |
| 3 | |
| 4 | ; Test that we can thread through the block with the partially redundant load (%2). |
| 5 | target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" |
| 6 | target triple = "i386-apple-darwin7" |
| 7 | |
| 8 | define i32 @foo(i32* %P) nounwind { |
| 9 | entry: |
| 10 | %0 = tail call i32 (...)* @f1() nounwind ; <i32> [#uses=1] |
| 11 | %1 = icmp eq i32 %0, 0 ; <i1> [#uses=1] |
| 12 | br i1 %1, label %bb1, label %bb |
| 13 | |
| 14 | bb: ; preds = %entry |
| 15 | store i32 42, i32* %P, align 4 |
| 16 | br label %bb1 |
| 17 | |
| 18 | bb1: ; preds = %entry, %bb |
| 19 | %res.0 = phi i32 [ 1, %bb ], [ 0, %entry ] ; <i32> [#uses=2] |
| 20 | %2 = load i32* %P, align 4 ; <i32> [#uses=1] |
| 21 | %3 = icmp sgt i32 %2, 36 ; <i1> [#uses=1] |
| 22 | br i1 %3, label %bb3, label %bb2 |
| 23 | |
| 24 | bb2: ; preds = %bb1 |
| 25 | %4 = tail call i32 (...)* @f2() nounwind ; <i32> [#uses=0] |
| 26 | ret i32 %res.0 |
| 27 | |
| 28 | bb3: ; preds = %bb1 |
| 29 | ret i32 %res.0 |
| 30 | } |
| 31 | |
| 32 | declare i32 @f1(...) |
| 33 | |
| 34 | declare i32 @f2(...) |