hanchenye-llvm-project/llvm/lib/Analysis
Hans Wennborg 45172aceb3 LazyValueInfo: Actually re-visit partially solved block-values in solveBlockValue()
If solveBlockValue() needs results from predecessors that are not already
computed, it returns false with the intention of resuming when the dependencies
have been resolved. However, the computation would never be resumed since an
'overdefined' result had been placed in the cache, preventing any further
computation.

The point of placing the 'overdefined' result in the cache seems to have been
to break cycles, but we can check for that when inserting work items in the
BlockValue stack instead. This makes the "stop and resume" mechanism of
solveBlockValue() work as intended, unlocking more analysis.

Using this patch shaves 120 KB off a 64-bit Chromium build on Linux.

I benchmarked compiling bzip2.c at -O2 but couldn't measure any difference in
compile time.

Tests by Jiangning Liu from r215343 / PR21238, Pete Cooper, and me.

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

llvm-svn: 222768
2014-11-25 17:23:05 +00:00
..
IPA Remove the unused FindUsedTypes pass. 2014-11-24 20:53:26 +00:00
AliasAnalysis.cpp Reformat partially, where I touched for whitespace changes. 2014-10-28 11:54:52 +00:00
AliasAnalysisCounter.cpp
AliasAnalysisEvaluator.cpp AA metadata refactoring (introduce AAMDNodes) 2014-07-24 12:16:19 +00:00
AliasDebugger.cpp
AliasSetTracker.cpp AliasSet: Simplify mergeSetIn 2014-11-19 19:36:18 +00:00
Analysis.cpp Revert "Don't make assumptions about the name of private global variables." 2014-11-15 02:03:53 +00:00
AssumptionTracker.cpp Clean up assume intrinsic pattern matching, no need to check that the argument is a value. 2014-10-25 18:09:01 +00:00
BasicAliasAnalysis.cpp Update SetVector to rely on the underlying set's insert to return a pair<iterator, bool> 2014-11-19 07:49:26 +00:00
BlockFrequencyInfo.cpp
BlockFrequencyInfoImpl.cpp [modules] Stop excluding Support/Debug.h from the Support module. This header 2014-10-13 00:41:03 +00:00
BranchProbabilityInfo.cpp Revert "IR: MDNode => Value" 2014-11-11 21:30:22 +00:00
CFG.cpp Update SetVector to rely on the underlying set's insert to return a pair<iterator, bool> 2014-11-19 07:49:26 +00:00
CFGPrinter.cpp Modernize raw_fd_ostream's constructor a bit. 2014-08-25 18:16:47 +00:00
CFLAliasAnalysis.cpp Remove redundant virtual on overriden functions. 2014-11-14 19:06:36 +00:00
CGSCCPassManager.cpp
CMakeLists.txt Add file to CMake build as well. 2014-09-18 00:39:20 +00:00
CaptureTracking.cpp Update SetVector to rely on the underlying set's insert to return a pair<iterator, bool> 2014-11-19 07:49:26 +00:00
CodeMetrics.cpp Update SetVector to rely on the underlying set's insert to return a pair<iterator, bool> 2014-11-19 07:49:26 +00:00
ConstantFolding.cpp Update SetVector to rely on the underlying set's insert to return a pair<iterator, bool> 2014-11-19 07:49:26 +00:00
CostModel.cpp
Delinearization.cpp
DependenceAnalysis.cpp [DependenceAnalysis] Allow subscripts of different types 2014-11-16 16:52:44 +00:00
DomPrinter.cpp
DominanceFrontier.cpp
FunctionTargetTransformInfo.cpp Add a new pass FunctionTargetTransformInfo. This pass serves as a 2014-09-18 00:34:14 +00:00
IVUsers.cpp Update SetVector to rely on the underlying set's insert to return a pair<iterator, bool> 2014-11-19 07:49:26 +00:00
InstCount.cpp
InstructionSimplify.cpp InstSimplify: Handle some simple tautological comparisons 2014-11-25 02:55:48 +00:00
Interval.cpp
IntervalPartition.cpp
JumpInstrTableInfo.cpp Add Forward Control-Flow Integrity. 2014-11-11 21:08:02 +00:00
LLVMBuild.txt
LazyCallGraph.cpp Update SetVector to rely on the underlying set's insert to return a pair<iterator, bool> 2014-11-19 07:49:26 +00:00
LazyValueInfo.cpp LazyValueInfo: Actually re-visit partially solved block-values in solveBlockValue() 2014-11-25 17:23:05 +00:00
LibCallAliasAnalysis.cpp
LibCallSemantics.cpp remove function names from comments; NFC 2014-10-21 18:26:57 +00:00
Lint.cpp Update SetVector to rely on the underlying set's insert to return a pair<iterator, bool> 2014-11-19 07:49:26 +00:00
Loads.cpp Revert r220349 to re-instate r220277 with a fix for PR21330 -- quite 2014-11-25 08:20:27 +00:00
LoopInfo.cpp Revert "IR: MDNode => Value" 2014-11-11 21:30:22 +00:00
LoopPass.cpp Fix assertion in LICM doFinalization() 2014-09-24 16:48:31 +00:00
Makefile
MemDepPrinter.cpp
MemoryBuiltins.cpp Update SetVector to rely on the underlying set's insert to return a pair<iterator, bool> 2014-11-19 07:49:26 +00:00
MemoryDependenceAnalysis.cpp Update SetVector to rely on the underlying set's insert to return a pair<iterator, bool> 2014-11-19 07:49:26 +00:00
ModuleDebugInfoPrinter.cpp
NoAliasAnalysis.cpp Simplify code. No functionality change. 2014-10-05 12:21:57 +00:00
PHITransAddr.cpp Make use of @llvm.assume in ValueTracking (computeKnownBits, etc.) 2014-09-07 18:57:58 +00:00
PostDominators.cpp
PtrUseVisitor.cpp Update SetVector to rely on the underlying set's insert to return a pair<iterator, bool> 2014-11-19 07:49:26 +00:00
README.txt
RegionInfo.cpp
RegionPass.cpp
RegionPrinter.cpp
ScalarEvolution.cpp Update SetVector to rely on the underlying set's insert to return a pair<iterator, bool> 2014-11-19 07:49:26 +00:00
ScalarEvolutionAliasAnalysis.cpp AA metadata refactoring (introduce AAMDNodes) 2014-07-24 12:16:19 +00:00
ScalarEvolutionExpander.cpp Update SetVector to rely on the underlying set's insert to return a pair<iterator, bool> 2014-11-19 07:49:26 +00:00
ScalarEvolutionNormalization.cpp Fix typos in comments, NFC 2014-08-29 21:53:01 +00:00
ScopedNoAliasAA.cpp Revert "IR: MDNode => Value" 2014-11-11 21:30:22 +00:00
SparsePropagation.cpp
StratifiedSets.h Update SetVector to rely on the underlying set's insert to return a pair<iterator, bool> 2014-11-19 07:49:26 +00:00
TargetTransformInfo.cpp Masked Vector Load and Store Intrinsics. 2014-11-23 08:07:43 +00:00
Trace.cpp
TypeBasedAliasAnalysis.cpp Revert "IR: MDNode => Value" 2014-11-11 21:30:22 +00:00
ValueTracking.cpp Factor check for the assume intrinsic out of checks in computeKnownBitsFromAssume 2014-11-24 23:44:28 +00:00

README.txt

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))

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