blob: cce23ea319c86b316a15bae8f98e5c59129e58c3 [file] [log] [blame]
Evan Chengc3f507f2011-01-29 04:46:23 +00001; RUN: opt < %s -jump-threading -S | FileCheck %s
Chris Lattner69e067f2008-11-27 05:07:53 +00002; rdar://6402033
3
4; Test that we can thread through the block with the partially redundant load (%2).
5target 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"
6target triple = "i386-apple-darwin7"
7
8define i32 @foo(i32* %P) nounwind {
Evan Chengc3f507f2011-01-29 04:46:23 +00009; CHECK: foo
Chris Lattner69e067f2008-11-27 05:07:53 +000010entry:
11 %0 = tail call i32 (...)* @f1() nounwind ; <i32> [#uses=1]
12 %1 = icmp eq i32 %0, 0 ; <i1> [#uses=1]
13 br i1 %1, label %bb1, label %bb
14
15bb: ; preds = %entry
Evan Chengc3f507f2011-01-29 04:46:23 +000016; CHECK: bb1.thread:
17; CHECK: store
18; CHECK: br label %bb3
Chris Lattner69e067f2008-11-27 05:07:53 +000019 store i32 42, i32* %P, align 4
20 br label %bb1
21
22bb1: ; preds = %entry, %bb
23 %res.0 = phi i32 [ 1, %bb ], [ 0, %entry ] ; <i32> [#uses=2]
24 %2 = load i32* %P, align 4 ; <i32> [#uses=1]
25 %3 = icmp sgt i32 %2, 36 ; <i1> [#uses=1]
26 br i1 %3, label %bb3, label %bb2
27
28bb2: ; preds = %bb1
29 %4 = tail call i32 (...)* @f2() nounwind ; <i32> [#uses=0]
30 ret i32 %res.0
31
32bb3: ; preds = %bb1
Evan Chengc3f507f2011-01-29 04:46:23 +000033; CHECK: bb3:
34; CHECK: %res.01 = phi i32 [ 1, %bb1.thread ], [ 0, %bb1 ]
35; CHECK: ret i32 %res.01
Chris Lattner69e067f2008-11-27 05:07:53 +000036 ret i32 %res.0
37}
38
39declare i32 @f1(...)
40
41declare i32 @f2(...)