summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorKarl-Johan Karlsson <karl-johan.karlsson@ericsson.com>2018-05-22 08:46:48 +0000
committerKarl-Johan Karlsson <karl-johan.karlsson@ericsson.com>2018-05-22 08:46:48 +0000
commit11d68a619e3f1f1ea5d42441ae4145ae378d6f32 (patch)
tree46d2fdf430dea7f5e6c0040b0e686886b1ef1073 /llvm/test
parentcf377a143451f783547cb9358b0c81e8592efe2c (diff)
downloadbcm5719-llvm-11d68a619e3f1f1ea5d42441ae4145ae378d6f32.tar.gz
bcm5719-llvm-11d68a619e3f1f1ea5d42441ae4145ae378d6f32.zip
[LowerSwitch] Fixed faulty PHI node update
Summary: When lowerswitch merge several cases into a new default block it's not updating the PHI nodes accordingly. The code that update the PHI nodes for the default edge only update the first entry and do not remove the remaining ones, to make sure the number of entries match the number of predecessors. This is easily fixed by replacing the code that update the PHI node with the already existing utility function for updating PHI nodes. Reviewers: hans, reames, arsenm Reviewed By: arsenm Subscribers: wdng, llvm-commits Differential Revision: https://reviews.llvm.org/D47055 llvm-svn: 332960
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/Transforms/Util/lowerswitch.ll58
1 files changed, 57 insertions, 1 deletions
diff --git a/llvm/test/Transforms/Util/lowerswitch.ll b/llvm/test/Transforms/Util/lowerswitch.ll
index 1eddb43c1a0..70e1e239b3d 100644
--- a/llvm/test/Transforms/Util/lowerswitch.ll
+++ b/llvm/test/Transforms/Util/lowerswitch.ll
@@ -3,7 +3,7 @@
; Test that we don't crash and have a different basic block for each incoming edge.
define void @test0() {
; CHECK-LABEL: @test0
-; CHECK: %merge = phi i64 [ 1, %BB3 ], [ 0, %NewDefault ], [ 0, %NodeBlock5 ], [ 0, %LeafBlock1 ]
+; CHECK: %merge = phi i64 [ 1, %BB3 ], [ 0, %NodeBlock5 ], [ 0, %LeafBlock1 ], [ 0, %NewDefault ]
BB1:
switch i32 undef, label %BB2 [
i32 3, label %BB2
@@ -186,3 +186,59 @@ define void @test2(i32 %mode) {
._crit_edge: ; preds = %34, %0
ret void
}
+
+; Test that the PHI node in for.cond should have one entry for each predecessor
+; of its parent basic block after lowerswitch merged several cases into a new
+; default block.
+define void @test3() {
+; CHECK-LABEL: @test3
+entry:
+ br label %lbl1
+
+lbl1: ; preds = %cleanup, %entry
+ br label %lbl2
+
+lbl2: ; preds = %cleanup, %lbl1
+ br label %for.cond
+
+for.cond: ; preds = %cleanup, %cleanup, %lbl2
+; CHECK: for.cond:
+; CHECK: phi i16 [ undef, %lbl2 ], [ %b.3, %NewDefault ]{{$}}
+; CHECK: for.cond1:
+ %b.2 = phi i16 [ undef, %lbl2 ], [ %b.3, %cleanup ], [ %b.3, %cleanup ]
+ br label %for.cond1
+
+for.cond1: ; preds = %for.inc, %for.cond
+ %b.3 = phi i16 [ %b.2, %for.cond ], [ undef, %for.inc ]
+ %tobool = icmp ne i16 %b.3, 0
+ br i1 %tobool, label %for.body, label %for.end
+
+for.body: ; preds = %for.cond1
+ br i1 undef, label %if.then, label %for.inc
+
+if.then: ; preds = %for.body
+ br label %cleanup
+
+for.inc: ; preds = %for.body
+ br label %for.cond1
+
+for.end: ; preds = %for.cond1
+ br i1 undef, label %if.then4, label %for.body7
+
+if.then4: ; preds = %for.end
+ br label %cleanup
+
+for.body7: ; preds = %for.end
+ br label %cleanup
+
+cleanup: ; preds = %for.body7, %if.then4, %if.then
+ switch i32 undef, label %unreachable [
+ i32 0, label %for.cond
+ i32 2, label %lbl1
+ i32 5, label %for.cond
+ i32 3, label %lbl2
+ ]
+
+unreachable: ; preds = %cleanup
+ unreachable
+}
OpenPOWER on IntegriCloud