summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorWei Mi <wmi@google.com>2016-02-09 00:07:08 +0000
committerWei Mi <wmi@google.com>2016-02-09 00:07:08 +0000
commitfc1cab305f74f4ed6e81e2ebf33912f7ed3ebff6 (patch)
treef122e57c5cf5c7b624f5399004abd88845aa195d /llvm/lib
parent92e6c2896cb13cf4fec429679d1430df48fe9e6a (diff)
downloadbcm5719-llvm-fc1cab305f74f4ed6e81e2ebf33912f7ed3ebff6.tar.gz
bcm5719-llvm-fc1cab305f74f4ed6e81e2ebf33912f7ed3ebff6.zip
This patch is to fix PR26529 caused by r259736.
IndVarSimplify assumes scAddRecExpr to be expanded in literal form instead of canonical form by calling disableCanonicalMode after it creates SCEVExpander. When CanonicalMode is disabled, SCEVExpander::expand should always return PHI node for scAddRecExpr. r259736 broke the assumption. The fix is to let SCEVExpander::expand skip the reuse Value logic if CanonicalMode is false. In addition, Besides IndVarSimplify, LSR pass also calls disableCanonicalMode before doing rewrite. We can remove the original check of LSRMode in reuse Value logic and use CanonicalMode instead. llvm-svn: 260174
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Analysis/ScalarEvolutionExpander.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolutionExpander.cpp b/llvm/lib/Analysis/ScalarEvolutionExpander.cpp
index 49cdcf75818..45b0adac6ee 100644
--- a/llvm/lib/Analysis/ScalarEvolutionExpander.cpp
+++ b/llvm/lib/Analysis/ScalarEvolutionExpander.cpp
@@ -1645,10 +1645,9 @@ Value *SCEVExpander::expand(const SCEV *S) {
// Expand the expression into instructions.
SetVector<Value *> *Set = SE.getSCEVValues(S);
Value *V = nullptr;
- // If the expansion is in LSRMode, and the SCEV contains any sub scAddRecExpr
- // type SCEV, it will be expanded literally, to prevent LSR's transformed SCEV
- // from being reverted.
- if (!(LSRMode && SE.containsAddRecurrence(S))) {
+ // If the expansion is not in CanonicalMode, and the SCEV contains any
+ // sub scAddRecExpr type SCEV, it is required to expand the SCEV literally.
+ if (CanonicalMode || !SE.containsAddRecurrence(S)) {
// If S is scConstant, it may be worse to reuse an existing Value.
if (S->getSCEVType() != scConstant && Set) {
// Choose a Value from the set which dominates the insertPt.
OpenPOWER on IntegriCloud