llvm-6502/lib/Analysis
Andrew Trick 64925c55c6 Enable LSR IV Chains with sufficient heuristics.
These heuristics are sufficient for enabling IV chains by
default. Performance analysis has been done for i386, x86_64, and
thumbv7. The optimization is rarely important, but can significantly
speed up certain cases by eliminating spill code within the
loop. Unrolled loops are prime candidates for IV chains. In many
cases, the final code could still be improved with more target
specific optimization following LSR. The goal of this feature is for
LSR to make the best choice of induction variables.

Instruction selection may not completely take advantage of this
feature yet. As a result, there could be cases of slight code size
increase.

Code size can be worse on x86 because it doesn't support postincrement
addressing. In fact, when chains are formed, you may see redundant
address plus stride addition in the addressing mode. GenerateIVChains
tries to compensate for the common cases.

On ARM, code size increase can be mitigated by using postincrement
addressing, but downstream codegen currently misses some opportunities.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147826 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-10 01:45:08 +00:00
..
IPA
AliasAnalysis.cpp
AliasAnalysisCounter.cpp
AliasAnalysisEvaluator.cpp
AliasDebugger.cpp
AliasSetTracker.cpp
Analysis.cpp
BasicAliasAnalysis.cpp
BlockFrequencyInfo.cpp Add some constantness to BranchProbabilityInfo and BlockFrequnencyInfo. 2011-12-20 20:03:10 +00:00
BranchProbabilityInfo.cpp Make the unreachable probability much much heavier. The previous 2011-12-22 09:26:37 +00:00
CaptureTracking.cpp Change CaptureTracking to pass a Use* instead of a Value* when a value is 2011-12-28 23:24:21 +00:00
CFGPrinter.cpp
CMakeLists.txt
ConstantFolding.cpp
DbgInfoPrinter.cpp
DebugInfo.cpp Unweaken vtables as per http://llvm.org/docs/CodingStandards.html#ll_virtual_anch 2011-12-20 02:50:00 +00:00
DIBuilder.cpp Update language check. Do not ignore DW_LANG_Python. 2012-01-09 17:49:47 +00:00
DominanceFrontier.cpp Unweaken vtables as per http://llvm.org/docs/CodingStandards.html#ll_virtual_anch 2011-12-20 02:50:00 +00:00
DomPrinter.cpp
InlineCost.cpp Continue counting intrinsics as instructions (except when they aren't, such as 2011-12-21 20:26:03 +00:00
InstCount.cpp
InstructionSimplify.cpp PatternMatch: Introduce a matcher for instructions with the "exact" bit. Use it to simplify a few matchers. 2012-01-01 17:55:30 +00:00
Interval.cpp
IntervalPartition.cpp
IVUsers.cpp Put all IVUsers in the processed set. Allow querying IVUsers with isIVUserOrOperand. 2012-01-06 21:41:55 +00:00
LazyValueInfo.cpp
LibCallAliasAnalysis.cpp
LibCallSemantics.cpp
Lint.cpp
LLVMBuild.txt LLVMBuild: Introduce a common section which currently has a list of the 2011-12-12 22:45:54 +00:00
Loads.cpp
LoopDependenceAnalysis.cpp
LoopInfo.cpp Move Instruction::isSafeToSpeculativelyExecute out of VMCore and 2011-12-14 23:49:11 +00:00
LoopPass.cpp
Makefile
MemDepPrinter.cpp Fix a stupid typo in MemDepPrinter. 2011-12-14 02:54:39 +00:00
MemoryBuiltins.cpp
MemoryDependenceAnalysis.cpp Change CaptureTracking to pass a Use* instead of a Value* when a value is 2011-12-28 23:24:21 +00:00
ModuleDebugInfoPrinter.cpp
NoAliasAnalysis.cpp
PathNumbering.cpp
PathProfileInfo.cpp
PathProfileVerifier.cpp
PHITransAddr.cpp Move Instruction::isSafeToSpeculativelyExecute out of VMCore and 2011-12-14 23:49:11 +00:00
PostDominators.cpp
ProfileEstimatorPass.cpp
ProfileInfo.cpp
ProfileInfoLoader.cpp
ProfileInfoLoaderPass.cpp
ProfileVerifierPass.cpp
README.txt
RegionInfo.cpp
RegionPass.cpp
RegionPrinter.cpp
ScalarEvolution.cpp Expose isNonConstantNegative to users of ScalarEvolution. 2012-01-07 00:27:31 +00:00
ScalarEvolutionAliasAnalysis.cpp
ScalarEvolutionExpander.cpp Enable LSR IV Chains with sufficient heuristics. 2012-01-10 01:45:08 +00:00
ScalarEvolutionNormalization.cpp
SparsePropagation.cpp
Trace.cpp
TypeBasedAliasAnalysis.cpp
ValueTracking.cpp Generalize isSafeToSpeculativelyExecute to work on arbitrary 2012-01-04 23:01:09 +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))

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