[llvm] r269212 - [SCEVExpander] Don't break SSA in replaceCongruentIVs
Sanjoy Das via llvm-commits
llvm-commits at lists.llvm.org
Wed May 11 10:41:34 PDT 2016
Author: sanjoy
Date: Wed May 11 12:41:34 2016
New Revision: 269212
URL: http://llvm.org/viewvc/llvm-project?rev=269212&view=rev
Log:
[SCEVExpander] Don't break SSA in replaceCongruentIVs
`SCEVExpander::replaceCongruentIVs` bypasses `hoistIVInc` if both the
original and the isomorphic increments are PHI nodes. Doing this can
break SSA if the isomorphic increment is not dominated by the original
increment. Get rid of the bypass, and let `hoistIVInc` do the right
thing.
Fixes PR27232 (compile time crash/hang).
Added:
llvm/trunk/test/Analysis/ScalarEvolution/expander-replace-congruent-ivs.ll
Modified:
llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp
Modified: llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp?rev=269212&r1=269211&r2=269212&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp (original)
+++ llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp Wed May 11 12:41:34 2016
@@ -1820,8 +1820,7 @@ unsigned SCEVExpander::replaceCongruentI
IsomorphicInc->getType());
if (OrigInc != IsomorphicInc && TruncExpr == SE.getSCEV(IsomorphicInc) &&
SE.LI.replacementPreservesLCSSAForm(IsomorphicInc, OrigInc) &&
- ((isa<PHINode>(OrigInc) && isa<PHINode>(IsomorphicInc)) ||
- hoistIVInc(OrigInc, IsomorphicInc))) {
+ hoistIVInc(OrigInc, IsomorphicInc)) {
DEBUG_WITH_TYPE(DebugType,
dbgs() << "INDVARS: Eliminated congruent iv.inc: "
<< *IsomorphicInc << '\n');
Added: llvm/trunk/test/Analysis/ScalarEvolution/expander-replace-congruent-ivs.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/expander-replace-congruent-ivs.ll?rev=269212&view=auto
==============================================================================
--- llvm/trunk/test/Analysis/ScalarEvolution/expander-replace-congruent-ivs.ll (added)
+++ llvm/trunk/test/Analysis/ScalarEvolution/expander-replace-congruent-ivs.ll Wed May 11 12:41:34 2016
@@ -0,0 +1,41 @@
+; RUN: opt -S -indvars < %s | FileCheck %s
+
+target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-apple-macosx10.11.0"
+
+; SCEVExpander would try to RAUW %val_2 with %c.lcssa, breaking "def
+; dominates uses".
+
+define void @pr27232(i32 %val) {
+; CHECK-LABEL: @pr27232(
+entry:
+ br i1 undef, label %loop_0.cond, label %for.body.us
+
+for.body.us:
+ br label %loop_0.cond
+
+loop_0.cond:
+ %val_2 = phi i32 [ %val, %for.body.us ], [ undef, %entry ]
+ 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_2, %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_2, %loop_1.ph ]
+ %t.1 = phi i32 [ %val_2, %loop_1 ], [ %c.lcssa, %loop_1.ph ]
+ br i1 undef, label %leave, label %loop_1
+
+leave:
+ ret void
+}
More information about the llvm-commits
mailing list