summaryrefslogtreecommitdiffstats
path: root/llvm/test/Analysis/ScalarEvolution
diff options
context:
space:
mode:
authorSanjoy Das <sanjoy@playingwithpointers.com>2016-05-11 17:41:41 +0000
committerSanjoy Das <sanjoy@playingwithpointers.com>2016-05-11 17:41:41 +0000
commit4e8c80382ff29c0e1dddfed5f497d9a1d7d36263 (patch)
treeb7c3ce2bdc47162a56c8ba6781759d8f917567a3 /llvm/test/Analysis/ScalarEvolution
parentabb7b93eb9e21ea55a566b4f2c29b4fbd500906a (diff)
downloadbcm5719-llvm-4e8c80382ff29c0e1dddfed5f497d9a1d7d36263.tar.gz
bcm5719-llvm-4e8c80382ff29c0e1dddfed5f497d9a1d7d36263.zip
[SCEVExpander] Fix a failed cast<> assertion
SCEVExpander::replaceCongruentIVs assumes the backedge value of an SCEV-analysable PHI to always be an instruction, when this is not necessarily true. For now address this by bailing out of the optimization if the backedge value of the PHI is a non-Instruction. llvm-svn: 269213
Diffstat (limited to 'llvm/test/Analysis/ScalarEvolution')
-rw-r--r--llvm/test/Analysis/ScalarEvolution/expander-replace-congruent-ivs.ll70
1 files changed, 70 insertions, 0 deletions
diff --git a/llvm/test/Analysis/ScalarEvolution/expander-replace-congruent-ivs.ll b/llvm/test/Analysis/ScalarEvolution/expander-replace-congruent-ivs.ll
index 887b9db7f25..0adb92d671b 100644
--- a/llvm/test/Analysis/ScalarEvolution/expander-replace-congruent-ivs.ll
+++ b/llvm/test/Analysis/ScalarEvolution/expander-replace-congruent-ivs.ll
@@ -39,3 +39,73 @@ loop_1:
leave:
ret void
}
+
+
+; @ReplaceArg_0 and @ReplaceArg_1 used to trigger a failed cast<>
+; assertion in SCEVExpander.
+
+define void @ReplaceArg_0(i32 %val) {
+; CHECK-LABEL: @ReplaceArg_0(
+entry:
+ br i1 undef, label %loop_0.cond, label %for.body.us
+
+for.body.us:
+ br label %loop_0.cond
+
+loop_0.cond:
+ br i1 true, label %loop_0.ph, label %loop_1.ph
+
+loop_0.ph:
+ br label %loop_0
+
+loop_1.exit:
+ br label %loop_1.ph
+
+loop_1.ph:
+ %c.lcssa = phi i32 [ 0, %loop_0.cond ], [ %val, %loop_1.exit ]
+ br label %loop_1
+
+loop_0:
+ br i1 undef, label %loop_0, label %loop_1.exit
+
+loop_1:
+ %d.1 = phi i32 [ %c.lcssa, %loop_1 ], [ %val, %loop_1.ph ]
+ %t.1 = phi i32 [ %val, %loop_1 ], [ %c.lcssa, %loop_1.ph ]
+ br i1 undef, label %leave, label %loop_1
+
+leave:
+ ret void
+}
+
+define void @ReplaceArg_1(i32 %val) {
+; CHECK-LABEL: @ReplaceArg_1(
+entry:
+ br i1 undef, label %loop_0.cond, label %for.body.us
+
+for.body.us:
+ br label %loop_0.cond
+
+loop_0.cond:
+ br i1 true, label %loop_0.ph, label %loop_1.ph
+
+loop_0.ph:
+ br label %loop_0
+
+loop_1.exit:
+ br label %loop_1.ph
+
+loop_1.ph:
+ %c.lcssa = phi i32 [ 0, %loop_0.cond ], [ %val, %loop_1.exit ]
+ br label %loop_1
+
+loop_0:
+ br i1 undef, label %loop_0, label %loop_1.exit
+
+loop_1:
+ %t.1 = phi i32 [ %val, %loop_1 ], [ %c.lcssa, %loop_1.ph ]
+ %d.1 = phi i32 [ %c.lcssa, %loop_1 ], [ %val, %loop_1.ph ]
+ br i1 undef, label %leave, label %loop_1
+
+leave:
+ ret void
+}
OpenPOWER on IntegriCloud