This patch is to fix PR26529 caused by r259736.
authorWei Mi <wmi@google.com>
Tue, 9 Feb 2016 00:07:08 +0000 (00:07 +0000)
committerWei Mi <wmi@google.com>
Tue, 9 Feb 2016 00:07:08 +0000 (00:07 +0000)
commitfc1cab305f74f4ed6e81e2ebf33912f7ed3ebff6
treef122e57c5cf5c7b624f5399004abd88845aa195d
parent92e6c2896cb13cf4fec429679d1430df48fe9e6a
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
llvm/lib/Analysis/ScalarEvolutionExpander.cpp
llvm/test/Analysis/ScalarEvolution/scev-canonical-mode.ll [new file with mode: 0644]