llvm-6502/lib/Analysis
Chris Lattner 6da12e6767 Implement rdar://6295824 and PR6724 with two tiny changes
that can have a big effect :).  The first is to enable the
iterative SCC passmanager juice that kicks in when the
scc passmgr detects that a function pass has devirtualized
a call.  In this case, it will rerun all the passes it 
manages on the SCC, up to the iteration count limit (4). This
is useful because a function pass may devirualize a call, and
we want the inliner to inline it, or pruneeh to infer stuff
about it, etc.

The second patch is to add *all* call sites to the 
DevirtualizedCalls list the inliner uses.  This list is
about to get renamed, but the jist of this is that the 
inliner now reconsiders *all* inlined call sites as candidates
for further inlining.  The intuition is this that in cases 
like this:

f() { g(1); }     g(int x) { h(x); }

We analyze this bottom up, and may decide that it isn't 
profitable to inline H into G.  Next step, we decide that it is
profitable to inline G into F, and do so, which means that F 
now calls H.  Even though the call from G -> H may not have been
profitable to inline, the call from F -> H may be (in this case
because a constant allows folding etc).

In my spot checks, this doesn't have a big impact on code.  For
example, the LLC output for 252.eon grew from 0.02% (from
317252 to 317308) and 176.gcc actually shrunk by .3% (from 1525612
to 1520964 bytes).  252.eon never iterated in the SCC Passmgr,
176.gcc iterated at most 1 time.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@102823 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-01 01:15:56 +00:00
..
IPA Implement rdar://6295824 and PR6724 with two tiny changes 2010-05-01 01:15:56 +00:00
AliasAnalysis.cpp Partially address a README by having functionattrs consider calls to 2010-01-06 08:45:52 +00:00
AliasAnalysisCounter.cpp Fix a missing newline in debug output. 2010-03-01 17:42:55 +00:00
AliasAnalysisEvaluator.cpp clean up algorithm and remove operand order assumptions 2010-04-08 16:46:24 +00:00
AliasDebugger.cpp adopt getAdjustedAnalysisPointer in a few more passes. 2010-01-20 20:09:02 +00:00
AliasSetTracker.cpp Change dbgs() back to errs() as Chris requested. 2009-12-23 22:49:57 +00:00
Analysis.cpp "In order to ease automatic bindings generation, it would be helpful if boolean values were distinguishable from integers. The attached patch introduces "typedef int LLVMBool;", and uses LLVMBool instead of int throughout the C API, wherever a boolean value is called for." 2010-01-09 22:27:07 +00:00
BasicAliasAnalysis.cpp Revert 101465, it broke internal OpenGL testing. 2010-04-16 23:37:20 +00:00
CaptureTracking.cpp rename use_const_iterator to const_use_iterator for consistency's sake 2010-03-25 23:06:16 +00:00
CFGPrinter.cpp Remove includes of Support/Compiler.h that are no longer needed after the 2009-10-25 06:57:41 +00:00
CMakeLists.txt Update CMake build. 2010-04-08 18:52:18 +00:00
ConstantFolding.cpp Revert 101465, it broke internal OpenGL testing. 2010-04-16 23:37:20 +00:00
DbgInfoPrinter.cpp Remove dead debug info intrinsics. 2010-01-05 01:10:40 +00:00
DebugInfo.cpp Attach AT_APPLE_optimized attribute to optimized function's debug info. 2010-04-30 19:38:23 +00:00
DomPrinter.cpp Remove dead code in the dotty dominance tree printer. 2010-04-12 15:02:19 +00:00
InlineCost.cpp Dan recently disabled recursive inlining within a function, but we 2010-04-30 22:37:22 +00:00
InstCount.cpp Change dbgs() back to errs() as Chris requested. 2009-12-23 23:29:28 +00:00
InstructionSimplify.cpp move some select simplifications out out instcombine into 2010-04-20 05:32:14 +00:00
Interval.cpp Change Pass::print to take a raw ostream instead of std::ostream, 2009-08-23 06:03:38 +00:00
IntervalPartition.cpp Change Pass::print to take a raw ostream instead of std::ostream, 2009-08-23 06:03:38 +00:00
IVUsers.cpp Remove the Expr member from IVUsers. Instead of remembering the expression, 2010-04-19 21:48:58 +00:00
LazyValueInfo.cpp Convert debug messages to use dbgs(). Generally this means 2009-12-23 20:43:58 +00:00
LibCallAliasAnalysis.cpp LibCallAliasAnalysis doesn't use TargetData. 2009-07-31 20:56:29 +00:00
LibCallSemantics.cpp Remove Value::getNameLen 2009-07-26 08:34:35 +00:00
Lint.cpp Add lint checks for invalid uses of memory. 2010-04-30 19:05:00 +00:00
LiveValues.cpp rename use_const_iterator to const_use_iterator for consistency's sake 2010-03-25 23:06:16 +00:00
LoopDependenceAnalysis.cpp Define placement new wrappers for BumpPtrAllocator and 2010-03-18 18:49:47 +00:00
LoopInfo.cpp Fix a bunch of namespace polution. 2010-04-15 17:08:50 +00:00
LoopPass.cpp Ok, third time's the charm. No changes from last time except the CMake 2010-04-02 23:17:14 +00:00
Makefile make -fno-rtti the default unless a directory builds with REQUIRES_RTTI. 2010-01-24 20:43:08 +00:00
MemoryBuiltins.cpp Revert 101465, it broke internal OpenGL testing. 2010-04-16 23:37:20 +00:00
MemoryDependenceAnalysis.cpp Revert 101465, it broke internal OpenGL testing. 2010-04-16 23:37:20 +00:00
PHITransAddr.cpp Reapply r97010, the speculative revert failed. 2010-02-24 08:48:04 +00:00
PointerTracking.cpp Rename isLoopGuardedByCond to isLoopEntryGuardedByCond, to emphasise 2010-04-11 19:27:13 +00:00
PostDominators.cpp Remove unneeded debug in PostDominator runOnFunction() 2010-04-12 15:32:55 +00:00
ProfileEstimatorPass.cpp rename pred_const_iterator to const_pred_iterator for consistency's sake 2010-03-25 23:25:28 +00:00
ProfileInfo.cpp rename pred_const_iterator to const_pred_iterator for consistency's sake 2010-03-25 23:25:28 +00:00
ProfileInfoLoader.cpp Reapplied r81355 with the problems fixed. 2009-09-16 11:35:50 +00:00
ProfileInfoLoaderPass.cpp rename pred_const_iterator to const_pred_iterator for consistency's sake 2010-03-25 23:25:28 +00:00
ProfileVerifierPass.cpp rename pred_const_iterator to const_pred_iterator for consistency's sake 2010-03-25 23:25:28 +00:00
README.txt When checking whether the special handling for an addrec increment which 2010-04-26 21:46:36 +00:00
ScalarEvolution.cpp Set isSigned to true when creating an all-ones integer constant, even 2010-04-30 19:22:39 +00:00
ScalarEvolutionAliasAnalysis.cpp Add a comment. 2010-03-01 17:56:04 +00:00
ScalarEvolutionExpander.cpp When checking whether the special handling for an addrec increment which 2010-04-26 21:46:36 +00:00
ScalarEvolutionNormalization.cpp Generalize IVUsers to track arbitrary expressions rather than expressions 2010-04-07 22:27:08 +00:00
SparsePropagation.cpp Convert debug messages to use dbgs(). Generally this means 2009-12-23 22:28:01 +00:00
Trace.cpp Convert debug messages to use dbgs(). Generally this means 2009-12-23 22:35:10 +00:00
ValueTracking.cpp Revert 101465, it broke internal OpenGL testing. 2010-04-16 23:37: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))

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