llvm-6502/lib/Analysis
Jingyue Wu e4d0a5ec18 [ValueTracking] Extend range metadata to call/invoke
Summary:
With this patch, range metadata can be added to call/invoke including
IntrinsicInst. Previously, it could only be added to load.

Rename computeKnownBitsLoad to computeKnownBitsFromRangeMetadata because
range metadata is not only used by load.

Update the language reference to reflect this change.

Test Plan:
Add several tests in range-2.ll to confirm the verifier is happy with
having range metadata on call/invoke.

Add two tests in AddOverFlow.ll to confirm annotating range metadata to
call/invoke can benefit InstCombine.

Reviewers: meheff, nlewycky, reames, hfinkel, eliben

Reviewed By: eliben

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211281 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-19 16:50:16 +00:00
..
IPA Removing an "if (!this)" check from two print methods. The condition will 2014-06-09 22:53:16 +00:00
AliasAnalysis.cpp
AliasAnalysisCounter.cpp
AliasAnalysisEvaluator.cpp
AliasDebugger.cpp
AliasSetTracker.cpp
Analysis.cpp Add a new attribute called 'jumptable' that creates jump-instruction tables for functions marked with this attribute. 2014-06-05 19:29:43 +00:00
BasicAliasAnalysis.cpp
BlockFrequencyInfo.cpp
BlockFrequencyInfoImpl.cpp blockfreq: Move include to .cpp 2014-05-06 01:57:42 +00:00
BranchProbabilityInfo.cpp
CaptureTracking.cpp
CFG.cpp
CFGPrinter.cpp Clean up language and grammar. 2014-05-20 17:11:11 +00:00
CGSCCPassManager.cpp
CMakeLists.txt Add a new attribute called 'jumptable' that creates jump-instruction tables for functions marked with this attribute. 2014-06-05 19:29:43 +00:00
CodeMetrics.cpp
ConstantFolding.cpp Remove old fenv.h workaround for a historic clang driver bug 2014-06-09 19:00:52 +00:00
CostModel.cpp
Delinearization.cpp remove BasePointer before delinearizing 2014-05-27 22:41:51 +00:00
DependenceAnalysis.cpp remove BasePointer before delinearizing 2014-05-27 22:41:51 +00:00
DominanceFrontier.cpp
DomPrinter.cpp
InstCount.cpp
InstructionSimplify.cpp Move optimization of some cases of (A & C1)|(B & C2) from instcombine to instsimplify. Patch by Rahul Jain, plus some last minute changes by me -- you can blame me for any bugs. 2014-06-19 03:51:46 +00:00
Interval.cpp
IntervalPartition.cpp
IVUsers.cpp Removing an "if (!this)" check from two print methods. The condition will 2014-06-09 22:53:16 +00:00
JumpInstrTableInfo.cpp Add a new attribute called 'jumptable' that creates jump-instruction tables for functions marked with this attribute. 2014-06-05 19:29:43 +00:00
LazyCallGraph.cpp Fix typos 2014-05-15 01:52:21 +00:00
LazyValueInfo.cpp
LibCallAliasAnalysis.cpp
LibCallSemantics.cpp
Lint.cpp Rename ComputeMaskedBits to computeKnownBits. "Masked" has been 2014-05-14 21:14:37 +00:00
LLVMBuild.txt
Loads.cpp
LoopInfo.cpp
LoopPass.cpp Removing an "if (!this)" check from two print methods. The condition will 2014-06-09 22:53:16 +00:00
Makefile
MemDepPrinter.cpp
MemoryBuiltins.cpp
MemoryDependenceAnalysis.cpp
ModuleDebugInfoPrinter.cpp
NoAliasAnalysis.cpp
PHITransAddr.cpp
PostDominators.cpp
PtrUseVisitor.cpp
README.txt
RegionInfo.cpp
RegionPass.cpp Removing an "if (!this)" check from two print methods. The condition will 2014-06-09 22:53:16 +00:00
RegionPrinter.cpp
ScalarEvolution.cpp ScalarEvolution: Derive element size from the type of the loaded element 2014-06-08 19:21:20 +00:00
ScalarEvolutionAliasAnalysis.cpp
ScalarEvolutionExpander.cpp
ScalarEvolutionNormalization.cpp test check-in: added missing parenthesis in comment 2014-05-28 19:03:33 +00:00
SparsePropagation.cpp
TargetTransformInfo.cpp
Trace.cpp
TypeBasedAliasAnalysis.cpp [TBAA] Fix handling of mixed TBAA (path-aware and non-path-aware TBAA). 2014-05-03 22:32:52 +00:00
ValueTracking.cpp [ValueTracking] Extend range metadata to call/invoke 2014-06-19 16:50:16 +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))

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