summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/SROA/phi-and-select.ll
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2012-09-25 10:03:40 +0000
committerChandler Carruth <chandlerc@gmail.com>2012-09-25 10:03:40 +0000
commit8b907e8acbacc4485b0c5cc4777d5d5844ece52d (patch)
treeed0f5742ed70e586e323e31303a2b7ab108d0bce /llvm/test/Transforms/SROA/phi-and-select.ll
parent3f4d0b17246e70dba8978d668e80b57641ddc5b8 (diff)
downloadbcm5719-llvm-8b907e8acbacc4485b0c5cc4777d5d5844ece52d.tar.gz
bcm5719-llvm-8b907e8acbacc4485b0c5cc4777d5d5844ece52d.zip
Fix a case where SROA did not correctly detect dead PHI or selects due
to chains or cycles between PHIs and/or selects. Also add a couple of really nice test cases reduced from Kostya's reports in PR13905 and PR13906. Both are fixed by this patch. llvm-svn: 164596
Diffstat (limited to 'llvm/test/Transforms/SROA/phi-and-select.ll')
-rw-r--r--llvm/test/Transforms/SROA/phi-and-select.ll45
1 files changed, 45 insertions, 0 deletions
diff --git a/llvm/test/Transforms/SROA/phi-and-select.ll b/llvm/test/Transforms/SROA/phi-and-select.ll
index ad0c55748dd..b55d917f728 100644
--- a/llvm/test/Transforms/SROA/phi-and-select.ll
+++ b/llvm/test/Transforms/SROA/phi-and-select.ll
@@ -327,3 +327,48 @@ exit:
%load = load i32* %a
ret i32 %load
}
+
+define i32 @PR13905() {
+; Check a pattern where we have a chain of dead phi nodes to ensure they are
+; deleted and promotion can proceed.
+; CHECK: @PR13905
+; CHECK-NOT: alloca i32
+; CHECK: ret i32 undef
+
+entry:
+ %h = alloca i32
+ store i32 0, i32* %h
+ br i1 undef, label %loop1, label %exit
+
+loop1:
+ %phi1 = phi i32* [ null, %entry ], [ %h, %loop1 ], [ %h, %loop2 ]
+ br i1 undef, label %loop1, label %loop2
+
+loop2:
+ br i1 undef, label %loop1, label %exit
+
+exit:
+ %phi2 = phi i32* [ %phi1, %loop2 ], [ null, %entry ]
+ ret i32 undef
+}
+
+define i32 @PR13906() {
+; Another pattern which can lead to crashes due to failing to clear out dead
+; PHI nodes or select nodes. This triggers subtly differently from the above
+; cases because the PHI node is (recursively) alive, but the select is dead.
+; CHECK: @PR13906
+; CHECK-NOT: alloca
+
+entry:
+ %c = alloca i32
+ store i32 0, i32* %c
+ br label %for.cond
+
+for.cond:
+ %d.0 = phi i32* [ undef, %entry ], [ %c, %if.then ], [ %d.0, %for.cond ]
+ br i1 undef, label %if.then, label %for.cond
+
+if.then:
+ %tmpcast.d.0 = select i1 undef, i32* %c, i32* %d.0
+ br label %for.cond
+}
OpenPOWER on IntegriCloud