llvm-6502/lib/Analysis
Sanjoy Das 011536a1cc [SCEV] Fix PR22856.
Summary:
ScalarEvolutionExpander assumes that the header block of a loop is a
legal place to have a use for a phi node.  This is true only for phis
that are either in the header or dominate the header block, but it is
not true for phi nodes that are strictly internal to the loop body.

This change teaches ScalarEvolutionExpander to place uses of PHI nodes
in the basic block the PHI nodes belong to.  This is always legal, and
`hoistIVInc` ensures that the said position dominates `IsomorphicInc`.

Reviewers: atrick

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D8311

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232189 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-13 18:31:19 +00:00
..
IPA removed function names from comments; NFC 2015-03-10 03:48:14 +00:00
AliasAnalysis.cpp DataLayout is mandatory, update the API to reflect it with references. 2015-03-10 02:37:25 +00:00
AliasAnalysisCounter.cpp Make DataLayout Non-Optional in the Module 2015-03-04 18:43:29 +00:00
AliasAnalysisEvaluator.cpp
AliasDebugger.cpp Make DataLayout Non-Optional in the Module 2015-03-04 18:43:29 +00:00
AliasSetTracker.cpp
Analysis.cpp Remove the Forward Control Flow Integrity pass and its dependencies. 2015-02-27 19:03:38 +00:00
AssumptionCache.cpp
BasicAliasAnalysis.cpp DataLayout is mandatory, update the API to reflect it with references. 2015-03-10 02:37:25 +00:00
BlockFrequencyInfo.cpp
BlockFrequencyInfoImpl.cpp
BranchProbabilityInfo.cpp
CaptureTracking.cpp
CFG.cpp
CFGPrinter.cpp
CFLAliasAnalysis.cpp Added ConstantExpr support to CFLAA. 2015-03-10 02:58:15 +00:00
CGSCCPassManager.cpp
CMakeLists.txt Remove the Forward Control Flow Integrity pass and its dependencies. 2015-02-27 19:03:38 +00:00
CodeMetrics.cpp
ConstantFolding.cpp DataLayout is mandatory, update the API to reflect it with references. 2015-03-10 02:37:25 +00:00
CostModel.cpp
Delinearization.cpp
DependenceAnalysis.cpp Fix a memory corruption in Dependency Analysis. 2015-03-10 14:32:02 +00:00
DominanceFrontier.cpp
DomPrinter.cpp
InstCount.cpp
InstructionSimplify.cpp DataLayout is mandatory, update the API to reflect it with references. 2015-03-10 02:37:25 +00:00
Interval.cpp
IntervalPartition.cpp
IVUsers.cpp DataLayout is mandatory, update the API to reflect it with references. 2015-03-10 02:37:25 +00:00
LazyCallGraph.cpp
LazyValueInfo.cpp DataLayout is mandatory, update the API to reflect it with references. 2015-03-10 02:37:25 +00:00
LibCallAliasAnalysis.cpp Make DataLayout Non-Optional in the Module 2015-03-04 18:43:29 +00:00
LibCallSemantics.cpp Stop calling DwarfEHPrepare from WinEHPrepare 2015-03-12 00:36:20 +00:00
Lint.cpp DataLayout is mandatory, update the API to reflect it with references. 2015-03-10 02:37:25 +00:00
LLVMBuild.txt
Loads.cpp DataLayout is mandatory, update the API to reflect it with references. 2015-03-10 02:37:25 +00:00
LoopAccessAnalysis.cpp [LoopAccesses] Add debug message to indicate the result of the analysis 2015-03-10 21:47:39 +00:00
LoopInfo.cpp
LoopPass.cpp
Makefile
MemDepPrinter.cpp MemDepPrinter: Fix some nits introduced in r228596 2015-02-25 23:55:00 +00:00
MemDerefPrinter.cpp DataLayout is mandatory, update the API to reflect it with references. 2015-03-10 02:37:25 +00:00
MemoryBuiltins.cpp DataLayout is mandatory, update the API to reflect it with references. 2015-03-10 02:37:25 +00:00
MemoryDependenceAnalysis.cpp DataLayout is mandatory, update the API to reflect it with references. 2015-03-10 02:37:25 +00:00
ModuleDebugInfoPrinter.cpp DebugInfo: Move new hierarchy into place 2015-03-03 17:24:31 +00:00
NoAliasAnalysis.cpp Make DataLayout Non-Optional in the Module 2015-03-04 18:43:29 +00:00
PHITransAddr.cpp
PostDominators.cpp
PtrUseVisitor.cpp
README.txt
RegionInfo.cpp
RegionPass.cpp Avoid calls to dumpPassInfo and RegionBase<Tr>::getNameStr() in RGPassManager if 2015-03-06 16:15:04 +00:00
RegionPrinter.cpp
ScalarEvolution.cpp When forming an addrec out of a phi don't just look at the last computation and steal its flags for our own, there may be other computations in the middle. Check whether the LHS of the computation is the phi itself and then we know it's safe to steal the flags. Fixes PR22795. 2015-03-13 01:37:52 +00:00
ScalarEvolutionAliasAnalysis.cpp Make DataLayout Non-Optional in the Module 2015-03-04 18:43:29 +00:00
ScalarEvolutionExpander.cpp [SCEV] Fix PR22856. 2015-03-13 18:31:19 +00:00
ScalarEvolutionNormalization.cpp
ScopedNoAliasAA.cpp Make DataLayout Non-Optional in the Module 2015-03-04 18:43:29 +00:00
SparsePropagation.cpp
StratifiedSets.h
TargetLibraryInfo.cpp Make static variables const if possible. Makes them go into a read-only section. 2015-03-08 16:07:39 +00:00
TargetTransformInfo.cpp Do not restrict interleaved unrolling to small loops, depending on the target. 2015-03-06 23:12:04 +00:00
Trace.cpp
TypeBasedAliasAnalysis.cpp Teach TBAA analysis to report errors on cyclic TBAA metadata rather than hanging. 2015-03-13 07:09:33 +00:00
ValueTracking.cpp Infer known bits from dominating conditions 2015-03-10 22:43:20 +00:00

Analysis Opportunities:

//===---------------------------------------------------------------------===//

In test/Transforms/LoopStrengthReduce/quadradic-exit-value.ll, the
ScalarEvolution expression for %r is this:

  {1,+,3,+,2}<loop>

Outside the loop, this could be evaluated simply as (%n * %n), however
ScalarEvolution currently evaluates it as

  (-2 + (2 * (trunc i65 (((zext i64 (-2 + %n) to i65) * (zext i64 (-1 + %n) to i65)) /u 2) to i64)) + (3 * %n))

In addition to being much more complicated, it involves i65 arithmetic,
which is very inefficient when expanded into code.

//===---------------------------------------------------------------------===//

In formatValue in test/CodeGen/X86/lsr-delayed-fold.ll,

ScalarEvolution is forming this expression:

((trunc i64 (-1 * %arg5) to i32) + (trunc i64 %arg5 to i32) + (-1 * (trunc i64 undef to i32)))

This could be folded to

(-1 * (trunc i64 undef to i32))

//===---------------------------------------------------------------------===//