llvm-6502/lib/Analysis
Chandler Carruth 73527d30cd Fix a stunning oversight in the inline cost analysis. It was never
propagating one of the values it simplified to a constant across
a myriad of instructions. Notably, ptrtoint instructions when we had
a constant pointer (say, 0) didn't propagate that, blocking a massive
number of down-stream optimizations.

This was uncovered when investigating why we fail to inline and delete
the boilerplate in:

  void f() {
    std::vector<int> v;
    v.push_back(1);
  }

It turns out most of the efforts I've made thus far to improve the
analysis weren't making it far purely because of this. After this is
fixed, the store-to-load forwarding patch enables LLVM to optimize the
above to an empty function. We still can't nuke a second push_back, but
for different reasons.

There is a very real chance this will cause somewhat noticable changes
in inlining behavior, so please let me know if you see regressions (or
improvements!) because of this patch.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171196 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-28 14:43:42 +00:00
..
IPA Use the new script to sort the includes of every file under lib. 2012-12-03 16:50:05 +00:00
AliasAnalysis.cpp Rename the 'Attributes' class to 'Attribute'. It's going to represent a single attribute in the future. 2012-12-19 07:18:57 +00:00
AliasAnalysisCounter.cpp Use the new script to sort the includes of every file under lib. 2012-12-03 16:50:05 +00:00
AliasAnalysisEvaluator.cpp Use the new script to sort the includes of every file under lib. 2012-12-03 16:50:05 +00:00
AliasDebugger.cpp Use the new script to sort the includes of every file under lib. 2012-12-03 16:50:05 +00:00
AliasSetTracker.cpp Use the new script to sort the includes of every file under lib. 2012-12-03 16:50:05 +00:00
Analysis.cpp Use the new script to sort the includes of every file under lib. 2012-12-03 16:50:05 +00:00
BasicAliasAnalysis.cpp Optimistically analyse Phi cycles 2012-12-10 23:02:41 +00:00
BlockFrequencyInfo.cpp Use the new script to sort the includes of every file under lib. 2012-12-03 16:50:05 +00:00
BranchProbabilityInfo.cpp Use the new script to sort the includes of every file under lib. 2012-12-03 16:50:05 +00:00
CaptureTracking.cpp Give CaptureTracker::shouldExplore a base implementation. Most users want to do 2012-10-08 22:12:48 +00:00
CFGPrinter.cpp Use the new script to sort the includes of every file under lib. 2012-12-03 16:50:05 +00:00
CMakeLists.txt Add a new visitor for walking the uses of a pointer value. 2012-12-10 08:28:39 +00:00
CodeMetrics.cpp Add a new attribute, 'noduplicate'. If a function contains a noduplicate call, the call cannot be duplicated - Jump threading, loop unrolling, loop unswitching, and loop rotation are inhibited if they would duplicate the call. 2012-12-20 16:04:27 +00:00
ConstantFolding.cpp Use the new script to sort the includes of every file under lib. 2012-12-03 16:50:05 +00:00
CostModel.cpp Update the docs of the cost model. 2012-12-24 05:51:12 +00:00
DbgInfoPrinter.cpp Use the new script to sort the includes of every file under lib. 2012-12-03 16:50:05 +00:00
DependenceAnalysis.cpp Use the new script to sort the includes of every file under lib. 2012-12-03 16:50:05 +00:00
DominanceFrontier.cpp Use the new script to sort the includes of every file under lib. 2012-12-03 16:50:05 +00:00
DomPrinter.cpp remove the blank line from previous ci. 2012-02-04 03:18:47 +00:00
InlineCost.cpp Fix a stunning oversight in the inline cost analysis. It was never 2012-12-28 14:43:42 +00:00
InstCount.cpp Use the new script to sort the includes of every file under lib. 2012-12-03 16:50:05 +00:00
InstructionSimplify.cpp Teach instsimplify to use the constant folder where appropriate for 2012-12-28 14:23:29 +00:00
Interval.cpp Revert 'Fix a typo 'iff' => 'if''. iff is an abreviation of if and only if. See: http://en.wikipedia.org/wiki/If_and_only_if Commit 164767 2012-09-27 10:14:43 +00:00
IntervalPartition.cpp
IVUsers.cpp Use the new script to sort the includes of every file under lib. 2012-12-03 16:50:05 +00:00
LazyValueInfo.cpp Use the new script to sort the includes of every file under lib. 2012-12-03 16:50:05 +00:00
LibCallAliasAnalysis.cpp Use the new script to sort the includes of every file under lib. 2012-12-03 16:50:05 +00:00
LibCallSemantics.cpp
Lint.cpp Use the new script to sort the includes of every file under lib. 2012-12-03 16:50:05 +00:00
LLVMBuild.txt LLVMBuild: Introduce a common section which currently has a list of the 2011-12-12 22:45:54 +00:00
Loads.cpp Move TargetData to DataLayout. 2012-10-08 16:38:25 +00:00
LoopInfo.cpp Add a new attribute, 'noduplicate'. If a function contains a noduplicate call, the call cannot be duplicated - Jump threading, loop unrolling, loop unswitching, and loop rotation are inhibited if they would duplicate the call. 2012-12-20 16:04:27 +00:00
LoopPass.cpp Enable the new LoopInfo algorithm by default. 2012-06-26 04:11:38 +00:00
Makefile
MemDepPrinter.cpp Use the new script to sort the includes of every file under lib. 2012-12-03 16:50:05 +00:00
MemoryBuiltins.cpp Rename the 'Attributes' class to 'Attribute'. It's going to represent a single attribute in the future. 2012-12-19 07:18:57 +00:00
MemoryDependenceAnalysis.cpp Rename the 'Attributes' class to 'Attribute'. It's going to represent a single attribute in the future. 2012-12-19 07:18:57 +00:00
ModuleDebugInfoPrinter.cpp Use the new script to sort the includes of every file under lib. 2012-12-03 16:50:05 +00:00
NoAliasAnalysis.cpp Use the new script to sort the includes of every file under lib. 2012-12-03 16:50:05 +00:00
PathNumbering.cpp Use the new script to sort the includes of every file under lib. 2012-12-03 16:50:05 +00:00
PathProfileInfo.cpp Use the new script to sort the includes of every file under lib. 2012-12-03 16:50:05 +00:00
PathProfileVerifier.cpp Use the new script to sort the includes of every file under lib. 2012-12-03 16:50:05 +00:00
PHITransAddr.cpp Use the new script to sort the includes of every file under lib. 2012-12-03 16:50:05 +00:00
PostDominators.cpp Use the new script to sort the includes of every file under lib. 2012-12-03 16:50:05 +00:00
ProfileDataLoader.cpp Use the new script to sort the includes of every file under lib. 2012-12-03 16:50:05 +00:00
ProfileDataLoaderPass.cpp Add LLVMContext::emitWarning methods and use them. <rdar://problem/12867368> 2012-12-24 18:15:21 +00:00
ProfileEstimatorPass.cpp Use the new script to sort the includes of every file under lib. 2012-12-03 16:50:05 +00:00
ProfileInfo.cpp Use the new script to sort the includes of every file under lib. 2012-12-03 16:50:05 +00:00
ProfileInfoLoader.cpp Use the new script to sort the includes of every file under lib. 2012-12-03 16:50:05 +00:00
ProfileInfoLoaderPass.cpp Add LLVMContext::emitWarning methods and use them. <rdar://problem/12867368> 2012-12-24 18:15:21 +00:00
ProfileVerifierPass.cpp Use the new script to sort the includes of every file under lib. 2012-12-03 16:50:05 +00:00
PtrUseVisitor.cpp Hoist the GEP constant address offset computation to a common home on 2012-12-11 10:29:10 +00:00
README.txt
RegionInfo.cpp Use the new script to sort the includes of every file under lib. 2012-12-03 16:50:05 +00:00
RegionPass.cpp Remove the the block_node_iterator of Region, replace it by the block_iterator. 2012-08-27 13:49:24 +00:00
RegionPrinter.cpp Use the new script to sort the includes of every file under lib. 2012-12-03 16:50:05 +00:00
ScalarEvolution.cpp Use the new script to sort the includes of every file under lib. 2012-12-03 16:50:05 +00:00
ScalarEvolutionAliasAnalysis.cpp Use the new script to sort the includes of every file under lib. 2012-12-03 16:50:05 +00:00
ScalarEvolutionExpander.cpp Use the new script to sort the includes of every file under lib. 2012-12-03 16:50:05 +00:00
ScalarEvolutionNormalization.cpp More dead code removal (using -Wunreachable-code) 2012-01-20 21:51:11 +00:00
SparsePropagation.cpp Taken into account Duncan's comments for r149481 dated by 2nd Feb 2012: 2012-03-08 07:06:20 +00:00
Trace.cpp Use the new script to sort the includes of every file under lib. 2012-12-03 16:50:05 +00:00
TypeBasedAliasAnalysis.cpp Use the new script to sort the includes of every file under lib. 2012-12-03 16:50:05 +00:00
ValueTracking.cpp Remove trailing whitespace. 2012-12-22 19:15:35 +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))

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