llvm.org GIT mirror llvm / 01666bf
If succ has succ itself as one of the predecessors then do not merge current bb and succ even if bb's terminator is unconditional branch to succ. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45305 91177308-0d34-0410-b5e6-96231b3b80d8 Devang Patel 11 years ago
2 changed file(s) with 62 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
109109 // update the PHI nodes correctly.
110110 if (!isa(BB->begin()) || Succ->getSinglePredecessor()) return true;
111111
112 // If the predecessors of Succ are only BB and Succ itself, handle it.
112 // If the predecessors of Succ are only BB, handle it.
113113 bool IsSafe = true;
114114 for (pred_iterator PI = pred_begin(Succ), E = pred_end(Succ); PI != E; ++PI)
115 if (*PI != Succ && *PI != BB) {
115 if (*PI != BB) {
116116 IsSafe = false;
117117 break;
118118 }
0 ; RUN: llvm-as < %s | opt -std-compile-opts -disable-output
1
2 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"
3
4 define i32 @bork() {
5 entry:
6 %retval = alloca i32 ; [#uses=2]
7 %opt = alloca i32 ; [#uses=3]
8 %undo = alloca i32 ; [#uses=3]
9 %tmp = alloca i32 ; [#uses=3]
10 %"alloca point" = bitcast i32 0 to i32 ; [#uses=0]
11 store i32 0, i32* %undo, align 4
12 br label %bb5
13
14 bb: ; preds = %bb5
15 %tmp1 = load i32* %opt, align 4 ; [#uses=1]
16 switch i32 %tmp1, label %bb4 [
17 i32 102, label %bb3
18 i32 110, label %bb2
19 ]
20
21 bb2: ; preds = %bb
22 store i32 1, i32* %undo, align 4
23 br label %bb3
24
25 bb3: ; preds = %bb2, %bb
26 br label %bb5
27
28 bb4: ; preds = %bb
29 store i32 258, i32* %tmp, align 4
30 br label %bb13
31
32 bb5: ; preds = %bb3, %entry
33 %tmp6 = call i32 (...)* @foo( ) nounwind ; [#uses=1]
34 store i32 %tmp6, i32* %opt, align 4
35 %tmp7 = load i32* %opt, align 4 ; [#uses=1]
36 %tmp8 = icmp ne i32 %tmp7, -1 ; [#uses=1]
37 %tmp89 = zext i1 %tmp8 to i8 ; [#uses=1]
38 %toBool = icmp ne i8 %tmp89, 0 ; [#uses=1]
39 br i1 %toBool, label %bb, label %bb10
40
41 bb10: ; preds = %bb5
42 %tmp11 = load i32* %undo, align 4 ; [#uses=1]
43 %tmp12 = call i32 (...)* @bar( i32 %tmp11 ) nounwind ; [#uses=0]
44 store i32 1, i32* %tmp, align 4
45 br label %bb13
46
47 bb13: ; preds = %bb10, %bb4
48 %tmp14 = load i32* %tmp, align 4 ; [#uses=1]
49 store i32 %tmp14, i32* %retval, align 4
50 br label %return
51
52 return: ; preds = %bb13
53 %retval15 = load i32* %retval ; [#uses=1]
54 ret i32 %retval15
55 }
56
57 declare i32 @foo(...)
58
59 declare i32 @bar(...)