aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/ScalarEvolutionExpander.cpp
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/Analysis/ScalarEvolutionExpander.cpp
parent92e6c2896cb13cf4fec429679d1430df48fe9e6a (diff)
downloadllvm-fc1cab305f74f4ed6e81e2ebf33912f7ed3ebff6.zip
llvm-fc1cab305f74f4ed6e81e2ebf33912f7ed3ebff6.tar.gz
llvm-fc1cab305f74f4ed6e81e2ebf33912f7ed3ebff6.tar.bz2
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/Analysis/ScalarEvolutionExpander.cpp')
-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 49cdcf7..45b0ada 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.