hanchenye-llvm-project/llvm/lib/Analysis
Bruno Cardoso Lopes c29520c5b3 [InstSimplify] Support constant folding to vector of pointers
ConstantFolding crashes when trying to InstSimplify the following load:

@a = private unnamed_addr constant %mst {
     i8* inttoptr (i64 -1 to i8*),
     i8* inttoptr (i64 -1 to i8*)
}, align 8

%x = load <2 x i8*>* bitcast (%mst* @a to <2 x i8*>*), align 8

This patch fix this by adding support to this type of folding:

%x = load <2 x i8*>* bitcast (%mst* @a to <2 x i8*>*), align 8
==> gets folded to:
  %x = <2 x i8*> <i8* inttoptr (i64 -1 to i8*), i8* inttoptr (i64 -1 to i8*)>

llvm-svn: 220380
2014-10-22 12:18:48 +00:00
..
IPA Add functions for finding ephemeral values 2014-09-07 13:49:57 +00:00
AliasAnalysis.cpp Make AAMDNodes ctor and operator bool (!!!) explicit, mop up bugs and weirdness exposed by it. 2014-10-04 22:44:29 +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 AssumptionTracker: Don't create temporary CallbackVHs. 2014-10-11 19:13:01 +00:00
BasicAliasAnalysis.cpp Revert "[BasicAA] Revert "Revert r218714 - Make better use of zext and sign information."" 2014-10-09 19:48:12 +00:00
BlockFrequencyInfo.cpp Revert "Introduce a string_ostream string builder facilty" 2014-06-26 22:52:05 +00:00
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 "[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 [CFL-AA] CFL-AA should not assert on an va_arg instruction 2014-10-14 20:51:26 +00:00
CGSCCPassManager.cpp
CMakeLists.txt Add file to CMake build as well. 2014-09-18 00:39:20 +00:00
CaptureTracking.cpp Match semantics of PointerMayBeCapturedBefore to its name by default 2014-07-21 21:30:22 +00:00
CodeMetrics.cpp Treat the WorkSet used to find ephemeral values as double-ended 2014-10-15 17:34:48 +00:00
ConstantFolding.cpp [InstSimplify] Support constant folding to vector of pointers 2014-10-22 12:18:48 +00:00
CostModel.cpp [CostModel][x86] Improved cost model for alternate shuffles. 2014-07-03 22:24:18 +00:00
Delinearization.cpp
DependenceAnalysis.cpp Analysis: cleanup 2014-08-26 02:03:40 +00:00
DomPrinter.cpp
DominanceFrontier.cpp Templatify DominanceFrontier. 2014-07-12 21:59:52 +00:00
FunctionTargetTransformInfo.cpp Add a new pass FunctionTargetTransformInfo. This pass serves as a 2014-09-18 00:34:14 +00:00
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 InstCombine, InstSimplify: (%X /s C1) /s C2 isn't always 0 when C1 * C2 overflow 2014-10-11 10:20:01 +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 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
LLVMBuild.txt
LazyCallGraph.cpp
LazyValueInfo.cpp [LVI] Add some additional comments about caching and context instructions 2014-10-16 00:40:05 +00:00
LibCallAliasAnalysis.cpp
LibCallSemantics.cpp remove function names from comments; NFC 2014-10-21 18:26:57 +00:00
Lint.cpp Make use of @llvm.assume in ValueTracking (computeKnownBits, etc.) 2014-09-07 18:57:58 +00:00
Loads.cpp Revert "Teach the load analysis to allow finding available values which require" (r220277) 2014-10-21 23:49:52 +00:00
LoopInfo.cpp Introduce enum values for previously defined metadata types. (NFC) 2014-10-21 00:13:20 +00:00
LoopPass.cpp Fix assertion in LICM doFinalization() 2014-09-24 16:48:31 +00:00
Makefile
MemDepPrinter.cpp
MemoryBuiltins.cpp PR21145: Teach LLVM about C++14 sized deallocation functions. 2014-10-03 20:17:06 +00:00
MemoryDependenceAnalysis.cpp Silence a -Wsign-compare warning. NFC. 2014-10-02 13:17:11 +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
README.txt
RegionInfo.cpp Fix msc17 build. RegionInfo::RegionInfo::recalculate() doesn't make sense. 2014-07-20 03:57:51 +00:00
RegionPass.cpp Templatify RegionInfo so it works on MachineBasicBlocks 2014-07-19 18:29:29 +00:00
RegionPrinter.cpp Templatify RegionInfo so it works on MachineBasicBlocks 2014-07-19 18:29:29 +00:00
ScalarEvolution.cpp Revert "r219834 - Teach ScalarEvolution to sharpen range information" 2014-10-15 23:46:04 +00:00
ScalarEvolutionAliasAnalysis.cpp AA metadata refactoring (introduce AAMDNodes) 2014-07-24 12:16:19 +00:00
ScalarEvolutionExpander.cpp Make use of @llvm.assume in ValueTracking (computeKnownBits, etc.) 2014-09-07 18:57:58 +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 Add minnum / maxnum intrinsics 2014-10-21 23:00:20 +00:00
Trace.cpp
TypeBasedAliasAnalysis.cpp Add scoped-noalias metadata 2014-07-24 14:25:39 +00:00
ValueTracking.cpp Add minnum / maxnum intrinsics 2014-10-21 23:00:20 +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))

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