llvm-6502/lib/Analysis
Duncan Sands 6dc9e2bf74 Reapply commit 143214 with a fix: m_ICmp doesn't match conditions
with the given predicate, it matches any condition and returns the
predicate - d'oh!  Original commit message:
The expression icmp eq (select (icmp eq x, 0), 1, x), 0 folds to false.
Spotted by my super-optimizer in 186.crafty and 450.soplex.  We really
need a proper infrastructure for handling generalizations of this kind
of thing (which occur a lot), however this case is so simple that I decided
to go ahead and implement it directly.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143318 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-30 19:56:36 +00:00
..
IPA Simplify; no intended functional change. 2011-10-20 03:23:14 +00:00
AliasAnalysis.cpp Enhance alias analysis for atomic instructions a bit. Upgrade a couple alias-analysis tests to the new atomic instructions. 2011-09-26 20:15:28 +00:00
AliasAnalysisCounter.cpp
AliasAnalysisEvaluator.cpp
AliasDebugger.cpp
AliasSetTracker.cpp
Analysis.cpp
BasicAliasAnalysis.cpp Remove the old atomic instrinsics. autoupgrade functionality is included with this patch. 2011-10-06 23:20:49 +00:00
BlockFrequencyInfo.cpp Add pass printing support to BlockFrequencyInfo pass. The implementation 2011-10-19 10:12:41 +00:00
BranchProbabilityInfo.cpp Fix the API usage in loop probability heuristics. It was incorrectly 2011-10-25 09:47:41 +00:00
CaptureTracking.cpp
CFGPrinter.cpp
CMakeLists.txt
ConstantFolding.cpp
DbgInfoPrinter.cpp Fix for DbgInfoPrinter.cpp:174:12: warning: ‘LineNo’ may be used uninitialized in this function. 2011-09-21 23:34:23 +00:00
DebugInfo.cpp Update DebugInfoFinder to match recent debug info encoding changes. 2011-10-17 22:30:34 +00:00
DIBuilder.cpp Add a new wrapper node for a DILexicalBlock that encapsulates it and a 2011-10-11 22:59:11 +00:00
DominanceFrontier.cpp
DomPrinter.cpp
InlineCost.cpp A FIXME about block addresses and indirectbr. 2011-10-20 04:05:33 +00:00
InstCount.cpp
InstructionSimplify.cpp Reapply commit 143214 with a fix: m_ICmp doesn't match conditions 2011-10-30 19:56:36 +00:00
Interval.cpp
IntervalPartition.cpp
IVUsers.cpp Slightly more useful tracing. 2011-10-13 17:06:38 +00:00
LazyValueInfo.cpp
LibCallAliasAnalysis.cpp
LibCallSemantics.cpp
Lint.cpp
Loads.cpp
LoopDependenceAnalysis.cpp
LoopInfo.cpp
LoopPass.cpp
Makefile
MemDepPrinter.cpp Enhance the memdep interface so that users can tell the difference between a dependency which cannot be calculated and a path reaching the entry point of the function. This patch introduces isNonFuncLocal, which replaces isUnknown in some cases. 2011-10-13 22:14:57 +00:00
MemoryBuiltins.cpp
MemoryDependenceAnalysis.cpp Enhance the memdep interface so that users can tell the difference between a dependency which cannot be calculated and a path reaching the entry point of the function. This patch introduces isNonFuncLocal, which replaces isUnknown in some cases. 2011-10-13 22:14:57 +00:00
ModuleDebugInfoPrinter.cpp
NoAliasAnalysis.cpp
PathNumbering.cpp
PathProfileInfo.cpp
PathProfileVerifier.cpp
PHITransAddr.cpp
PostDominators.cpp
ProfileEstimatorPass.cpp
ProfileInfo.cpp
ProfileInfoLoader.cpp
ProfileInfoLoaderPass.cpp
ProfileVerifierPass.cpp
README.txt
RegionInfo.cpp
RegionPass.cpp
RegionPrinter.cpp
ScalarEvolution.cpp Restore commits 142790 and 142843 - they weren't breaking the build 2011-10-25 12:28:52 +00:00
ScalarEvolutionAliasAnalysis.cpp
ScalarEvolutionExpander.cpp Fix SCEVExpander assert during LSR: "argument of incompatible type". 2011-10-15 06:19:55 +00:00
ScalarEvolutionNormalization.cpp Fix memory corruption I introduced a few checkins ago. 2011-10-13 18:49:23 +00:00
SparsePropagation.cpp
Trace.cpp
TypeBasedAliasAnalysis.cpp
ValueTracking.cpp A shift of a power of two is a power of two or zero. 2011-10-28 18:30:05 +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))

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