[PATCH] D58113: [SCEV] Teach computeSCEVAtScope benefit from one-input Phi. PR39673
Philip Reames via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 12 10:20:23 PDT 2019
This revision was not accepted when it landed; it landed in state "Needs Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL363180: [SCEV] Teach computeSCEVAtScope benefit from one-input Phi. PR39673 (authored by reames, committed by ).
Herald added a project: LLVM.
Changed prior to commit:
https://reviews.llvm.org/D58113?vs=186435&id=204323#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D58113/new/
https://reviews.llvm.org/D58113
Files:
llvm/trunk/lib/Analysis/ScalarEvolution.cpp
llvm/trunk/test/Transforms/IndVarSimplify/pr39673.ll
Index: llvm/trunk/test/Transforms/IndVarSimplify/pr39673.ll
===================================================================
--- llvm/trunk/test/Transforms/IndVarSimplify/pr39673.ll
+++ llvm/trunk/test/Transforms/IndVarSimplify/pr39673.ll
@@ -21,8 +21,7 @@
; CHECK-NEXT: [[CMP2:%.*]] = icmp ult i16 [[L2_ADD]], 2
; CHECK-NEXT: br i1 [[CMP2]], label [[LOOP2]], label [[LOOP2_END:%.*]]
; CHECK: loop2.end:
-; CHECK-NEXT: [[K2_ADD_LCSSA:%.*]] = phi i16 [ [[K2_ADD]], [[LOOP2]] ]
-; CHECK-NEXT: ret i16 [[K2_ADD_LCSSA]]
+; CHECK-NEXT: ret i16 184
;
entry:
br label %loop1
Index: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
===================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolution.cpp
+++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp
@@ -8138,6 +8138,16 @@
if (RV) return getSCEV(RV);
}
}
+
+ // If there is a single-input Phi, evaluate it at our scope. If we can
+ // prove that this replacement does not break LCSSA form, use new value.
+ if (PN->getNumOperands() == 1) {
+ const SCEV *Input = getSCEV(PN->getOperand(0));
+ const SCEV *InputAtScope = getSCEVAtScope(Input, L);
+ // TODO: We can generalize it using LI.replacementPreservesLCSSAForm,
+ // for the simplest case just support constants.
+ if (isa<SCEVConstant>(InputAtScope)) return InputAtScope;
+ }
}
// Okay, this is an expression that we cannot symbolically evaluate
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58113.204323.patch
Type: text/x-patch
Size: 1539 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190612/2740e5c3/attachment.bin>
More information about the llvm-commits
mailing list