[PATCH] D77211: [LSR] do not replace PHI nodes if its scev is SCEVUnknown

ChenZheng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 1 04:25:07 PDT 2020


shchenz updated this revision to Diff 254164.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77211/new/

https://reviews.llvm.org/D77211

Files:
  llvm/lib/Analysis/ScalarEvolutionExpander.cpp
  llvm/test/Transforms/LoopStrengthReduce/phi-unknownscev.ll


Index: llvm/test/Transforms/LoopStrengthReduce/phi-unknownscev.ll
===================================================================
--- llvm/test/Transforms/LoopStrengthReduce/phi-unknownscev.ll
+++ llvm/test/Transforms/LoopStrengthReduce/phi-unknownscev.ll
@@ -18,8 +18,8 @@
 ; %scevgep9798 = bitcast %_elem_type_of_ap* %scevgep97 to [0 x %_elem_type_of_ap]*
 ; %lsr.iv99 = phi [0 x %_elem_type_of_ap]* [ %24, %_scf_2_skip_ ], [ %scevgep9798, %_loop_1_do_.lr.ph ]
 
-; CHECK: INDVARS: Eliminated congruent iv:
-; CHECK-NEXT: INDVARS: Original iv:
+; CHECK-NOT: INDVARS: Eliminated congruent iv:
+; CHECK-NOT: INDVARS: Original iv:
 
 define void @foo(i64* noalias %.n, float* noalias %.alpha, [0 x %_elem_type_of_x]* noalias %.x, [0 x %_elem_type_of_y]* noalias %.y, [0 x %_elem_type_of_ap]* noalias %.ap, i64* noalias %.lda) {
 entry:
Index: llvm/lib/Analysis/ScalarEvolutionExpander.cpp
===================================================================
--- llvm/lib/Analysis/ScalarEvolutionExpander.cpp
+++ llvm/lib/Analysis/ScalarEvolutionExpander.cpp
@@ -35,6 +35,10 @@
     cl::desc("When performing SCEV expansion only if it is cheap to do, this "
              "controls the budget that is considered cheap (default = 4)"));
 
+cl::opt<bool> EliminateSCEVUnknownPHI(
+    "eliminate-SCEVUnknown-phi", cl::Hidden, cl::init(false),
+    cl::desc("This controls congruent SCEVUnknown PHI node can be replaced."));
+
 using namespace PatternMatch;
 
 /// ReuseOrCreateCast - Arrange for there to be a cast of V to Ty at IP,
@@ -2002,7 +2006,11 @@
     if (!SE.isSCEVable(Phi->getType()))
       continue;
 
-    PHINode *&OrigPhiRef = ExprToIVMap[SE.getSCEV(Phi)];
+    const SCEV* S = SE.getSCEV(Phi);
+    if (!EliminateSCEVUnknownPHI && isa<SCEVUnknown>(S))
+      continue;
+
+    PHINode *&OrigPhiRef = ExprToIVMap[S];
     if (!OrigPhiRef) {
       OrigPhiRef = Phi;
       if (Phi->getType()->isIntegerTy() && TTI &&


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77211.254164.patch
Type: text/x-patch
Size: 1932 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200401/3bca9e4d/attachment.bin>


More information about the llvm-commits mailing list