hanchenye-llvm-project/llvm/lib/Analysis
Hal Finkel 74c2f355d2 Add an Assumption-Tracking Pass
This adds an immutable pass, AssumptionTracker, which keeps a cache of
@llvm.assume call instructions within a module. It uses callback value handles
to keep stale functions and intrinsics out of the map, and it relies on any
code that creates new @llvm.assume calls to notify it of the new instructions.
The benefit is that code needing to find @llvm.assume intrinsics can do so
directly, without scanning the function, thus allowing the cost of @llvm.assume
handling to be negligible when none are present.

The current design is intended to be lightweight. We don't keep track of
anything until we need a list of assumptions in some function. The first time
this happens, we scan the function. After that, we add/remove @llvm.assume
calls from the cache in response to registration calls and ValueHandle
callbacks.

There are no new direct test cases for this pass, but because it calls it
validation function upon module finalization, we'll pick up detectable
inconsistencies from the other tests that touch @llvm.assume calls.

This pass will be used by follow-up commits that make use of @llvm.assume.

llvm-svn: 217334
2014-09-07 12:44:26 +00:00
..
IPA Remove Support/IncludeFile.h and its only user. This is actively harmful, since 2014-08-07 20:41:17 +00:00
AliasAnalysis.cpp AA metadata refactoring (introduce AAMDNodes) 2014-07-24 12:16:19 +00:00
AliasAnalysisCounter.cpp
AliasAnalysisEvaluator.cpp AA metadata refactoring (introduce AAMDNodes) 2014-07-24 12:16:19 +00:00
AliasDebugger.cpp
AliasSetTracker.cpp AA metadata refactoring (introduce AAMDNodes) 2014-07-24 12:16:19 +00:00
Analysis.cpp Add a CFL Alias Analysis implementation 2014-09-02 21:43:13 +00:00
AssumptionTracker.cpp Add an Assumption-Tracking Pass 2014-09-07 12:44:26 +00:00
BasicAliasAnalysis.cpp Use range based for loops to avoid needing to re-mention SmallPtrSet size. 2014-08-24 23:23:06 +00:00
BlockFrequencyInfo.cpp
BlockFrequencyInfoImpl.cpp
BranchProbabilityInfo.cpp Revert "[C++11] Add predecessors(BasicBlock *) / successors(BasicBlock *) iterator ranges." 2014-07-21 17:06:51 +00:00
CFG.cpp
CFGPrinter.cpp Modernize raw_fd_ostream's constructor a bit. 2014-08-25 18:16:47 +00:00
CFLAliasAnalysis.cpp [CFLAA] Remove one final initializer list 2014-09-03 00:06:47 +00:00
CGSCCPassManager.cpp
CMakeLists.txt Add an Assumption-Tracking Pass 2014-09-07 12:44:26 +00:00
CaptureTracking.cpp Match semantics of PointerMayBeCapturedBefore to its name by default 2014-07-21 21:30:22 +00:00
CodeMetrics.cpp
ConstantFolding.cpp Repace SmallPtrSet with SmallPtrSetImpl in function arguments to avoid needing to mention the size. 2014-08-21 05:55:13 +00:00
CostModel.cpp
Delinearization.cpp
DependenceAnalysis.cpp Analysis: cleanup 2014-08-26 02:03:40 +00:00
DomPrinter.cpp
DominanceFrontier.cpp
IVUsers.cpp Repace SmallPtrSet with SmallPtrSetImpl in function arguments to avoid needing to mention the size. 2014-08-21 05:55:13 +00:00
InstCount.cpp
InstructionSimplify.cpp InstSimplify: Move a transform from InstCombine to InstSimplify 2014-08-28 03:34:28 +00:00
Interval.cpp Revert "[C++11] Add predecessors(BasicBlock *) / successors(BasicBlock *) iterator ranges." 2014-07-21 17:06:51 +00:00
IntervalPartition.cpp
JumpInstrTableInfo.cpp
LLVMBuild.txt
LazyCallGraph.cpp
LazyValueInfo.cpp In LVI(Lazy Value Info), originally value on a BB can only be caculated once, 2014-08-11 05:02:04 +00:00
LibCallAliasAnalysis.cpp
LibCallSemantics.cpp
Lint.cpp Repace SmallPtrSet with SmallPtrSetImpl in function arguments to avoid needing to mention the size. 2014-08-21 05:55:13 +00:00
Loads.cpp AA metadata refactoring (introduce AAMDNodes) 2014-07-24 12:16:19 +00:00
LoopInfo.cpp Revert "[C++11] Add predecessors(BasicBlock *) / successors(BasicBlock *) iterator ranges." 2014-07-21 17:06:51 +00:00
LoopPass.cpp
Makefile
MemDepPrinter.cpp
MemoryBuiltins.cpp
MemoryDependenceAnalysis.cpp Fix MemoryDependenceAnalysis in cases where QueryInstr is a CmpXchg or a AtomicRMW 2014-09-02 20:17:52 +00:00
ModuleDebugInfoPrinter.cpp
NoAliasAnalysis.cpp
PHITransAddr.cpp
PostDominators.cpp
PtrUseVisitor.cpp
README.txt
RegionInfo.cpp
RegionPass.cpp
RegionPrinter.cpp
ScalarEvolution.cpp Remove an errant outer loop that contains nothing but an inner loop over exactly the same elements. While no functionality is change intended (and hence there are no changes to tests), you don't want to skip this revision if bisecting for errors. 2014-09-01 05:17:15 +00:00
ScalarEvolutionAliasAnalysis.cpp AA metadata refactoring (introduce AAMDNodes) 2014-07-24 12:16:19 +00:00
ScalarEvolutionExpander.cpp Fix ScalarEvolutionExpander when creating a PHI in a block with duplicate predecessors 2014-07-31 19:13:38 +00:00
ScalarEvolutionNormalization.cpp Fix typos in comments, NFC 2014-08-29 21:53:01 +00:00
ScopedNoAliasAA.cpp Add override to overriden virtual methods, remove virtual keywords. 2014-09-03 11:41:21 +00:00
SparsePropagation.cpp
StratifiedSets.h [CFLAA] And even more MSVC fixes 2014-09-02 23:50:01 +00:00
TargetTransformInfo.cpp Remove 'virtual' keyword from methods markedwith 'override' keyword. 2014-08-30 16:48:34 +00:00
Trace.cpp
TypeBasedAliasAnalysis.cpp Add scoped-noalias metadata 2014-07-24 14:25:39 +00:00
ValueTracking.cpp Make fabs safe to speculatively execute 2014-08-29 16:01:17 +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))

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