llvm-6502/lib/Analysis
James Molloy d594ba0815 Reapply r237539 with a fix for the Chromium build.
Make sure if we're truncating a constant that would then be sign extended
that the sign extension of the truncated constant is the same as the
original constant.

> Canonicalize min/max expressions correctly.
>
> This patch introduces a canonical form for min/max idioms where one operand
> is extended or truncated. This often happens when the other operand is a
> constant. For example:
>
> %1 = icmp slt i32 %a, i32 0
> %2 = sext i32 %a to i64
> %3 = select i1 %1, i64 %2, i64 0
>
> Would now be canonicalized into:
>
> %1 = icmp slt i32 %a, i32 0
> %2 = select i1 %1, i32 %a, i32 0
> %3 = sext i32 %2 to i64
>
> This builds upon a patch posted by David Majenemer
> (https://www.marc.info/?l=llvm-commits&m=143008038714141&w=2). That pass
> passively stopped instcombine from ruining canonical patterns. This
> patch additionally actively makes instcombine canonicalize too.
>
> Canonicalization of expressions involving a change in type from int->fp
> or fp->int are not yet implemented.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237821 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-20 18:41:25 +00:00
..
IPA [Inliner] Don't inline functions with frameescape calls 2015-04-14 20:38:14 +00:00
AliasAnalysis.cpp Test commit: Remove unnecessary spaces. 2015-05-13 15:04:14 +00:00
AliasAnalysisCounter.cpp Use 'override/final' instead of 'virtual' for overridden methods 2015-04-11 02:11:45 +00:00
AliasAnalysisEvaluator.cpp [CallSite] Make construction from Value* (or Instruction*) explicit. 2015-04-10 14:50:08 +00:00
AliasDebugger.cpp Make DataLayout Non-Optional in the Module 2015-03-04 18:43:29 +00:00
AliasSetTracker.cpp Constify arguments in AliasSetTracker methods. NFC 2015-05-13 01:12:12 +00:00
Analysis.cpp Divergence analysis for GPU programs 2015-04-10 05:03:50 +00:00
AssumptionCache.cpp [PM] Actually add the new pass manager support for the assumption cache. 2015-01-22 21:53:09 +00:00
BasicAliasAnalysis.cpp Change Function::getIntrinsicID() to return an Intrinsic::ID. NFC. 2015-05-20 17:16:39 +00:00
BlockFrequencyInfo.cpp Remove superfluous .str() and replace std::string concatenation with Twine. 2015-03-27 17:51:30 +00:00
BlockFrequencyInfoImpl.cpp Remove 4,096 loop scale limitation. 2015-04-01 17:42:27 +00:00
BranchProbabilityInfo.cpp Fix information loss in branch probability computation. 2015-05-07 17:22:06 +00:00
CaptureTracking.cpp [cleanup] Re-sort all the #include lines in LLVM using 2015-01-14 11:23:27 +00:00
CFG.cpp Standardize {pred,succ,use,user}_empty() 2015-01-13 03:46:47 +00:00
CFGPrinter.cpp Remove superfluous .str() and replace std::string concatenation with Twine. 2015-03-27 17:51:30 +00:00
CFLAliasAnalysis.cpp Convert PHI getIncomingValue() to foreach over incoming_values(). NFC. 2015-05-12 20:05:31 +00:00
CGSCCPassManager.cpp [PM] Remove the defunt CGSCC-specific debug flag. 2015-01-13 22:45:13 +00:00
CMakeLists.txt Move IDF Calculation to a separate file, expose an interface to it. 2015-04-21 19:13:02 +00:00
CodeMetrics.cpp Re-sort includes with sort-includes.py and insert raw_ostream.h where it's used. 2015-03-23 19:32:43 +00:00
ConstantFolding.cpp [ConstantFolding] Fix wrong folding of intrinsic 'convert.from.fp16'. 2015-05-14 18:01:48 +00:00
CostModel.cpp [multiversion] Thread a function argument through all the callers of the 2015-02-01 12:01:35 +00:00
Delinearization.cpp [PM] Split the LoopInfo object apart from the legacy pass, creating 2015-01-17 14:16:18 +00:00
DependenceAnalysis.cpp [DependenceAnalysis] Fix for PR21585: collectUpperBound triggers asserts 2015-05-15 12:17:22 +00:00
DivergenceAnalysis.cpp Divergence analysis for GPU programs 2015-04-10 05:03:50 +00:00
DominanceFrontier.cpp Templatify DominanceFrontier. 2014-07-12 21:59:52 +00:00
DomPrinter.cpp [PM] Split DominatorTree into a concrete analysis result object which 2014-01-13 13:07:17 +00:00
InstCount.cpp [Modules] Fix potential ODR violations by sinking the DEBUG_TYPE 2014-04-22 02:48:03 +00:00
InstructionSimplify.cpp Change Function::getIntrinsicID() to return an Intrinsic::ID. NFC. 2015-05-20 17:16:39 +00:00
Interval.cpp Revert "[C++11] Add predecessors(BasicBlock *) / successors(BasicBlock *) iterator ranges." 2014-07-21 17:06:51 +00:00
IntervalPartition.cpp [C++11] More 'nullptr' conversion. In some cases just using a boolean check instead of comparing to nullptr. 2014-04-15 04:59:12 +00:00
IteratedDominanceFrontier.cpp Move IDF Calculation to a separate file, expose an interface to it. 2015-04-21 19:13:02 +00:00
IVUsers.cpp DataLayout is mandatory, update the API to reflect it with references. 2015-03-10 02:37:25 +00:00
LazyCallGraph.cpp Revert r225854: [PM] Move the LazyCallGraph printing functionality to 2015-01-14 00:27:45 +00:00
LazyValueInfo.cpp [ConstantRange] Split makeICmpRegion in two. 2015-03-18 00:41:24 +00:00
LibCallAliasAnalysis.cpp Make DataLayout Non-Optional in the Module 2015-03-04 18:43:29 +00:00
LibCallSemantics.cpp [WinEH] Start EH preparation for 32-bit x86, it uses no arguments 2015-04-29 22:49:54 +00:00
Lint.cpp Fix doxygen comments from r232268 2015-03-16 17:49:03 +00:00
LLVMBuild.txt Update libdeps since TLI was moved from Target to Analysis in r226078. 2015-01-15 05:21:00 +00:00
Loads.cpp DataLayout is mandatory, update the API to reflect it with references. 2015-03-10 02:37:25 +00:00
LoopAccessAnalysis.cpp [LoopAccesses] If shouldRetryWithRuntimeCheck, reset InterestingDependences 2015-05-18 15:37:03 +00:00
LoopInfo.cpp Add llvm::all_of which wraps std::all_of. 2015-05-13 22:19:13 +00:00
LoopPass.cpp Purge unused includes throughout libSupport. 2015-03-23 18:07:13 +00:00
Makefile
MemDepPrinter.cpp [CallSite] Make construction from Value* (or Instruction*) explicit. 2015-04-10 14:50:08 +00:00
MemDerefPrinter.cpp Move Value.isDereferenceablePointer to ValueTracking [NFC] 2015-04-23 17:36:48 +00:00
MemoryBuiltins.cpp DataLayout is mandatory, update the API to reflect it with references. 2015-03-10 02:37:25 +00:00
MemoryDependenceAnalysis.cpp Revamp PredIteratorCache interface to be cleaner. 2015-04-21 21:11:50 +00:00
ModuleDebugInfoPrinter.cpp IR: Give 'DI' prefix to debug info metadata 2015-04-29 16:38:44 +00:00
NoAliasAnalysis.cpp Make DataLayout Non-Optional in the Module 2015-03-04 18:43:29 +00:00
PHITransAddr.cpp [opaque pointer type] more gep API migration 2015-03-14 19:53:33 +00:00
PostDominators.cpp [Modules] Fix potential ODR violations by sinking the DEBUG_TYPE 2014-04-22 02:48:03 +00:00
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 [cleanup] Re-sort all the #include lines in LLVM using 2015-01-14 11:23:27 +00:00
RegionPass.cpp Change range-based for-loops to be -Wrange-loop-analysis clean. 2015-04-15 01:21:15 +00:00
RegionPrinter.cpp One more -Wrange-loop-analysis cleanup. 2015-04-15 21:40:50 +00:00
ScalarEvolution.cpp [ScalarEvolution] refactor: extract interface getGEPExpr 2015-05-18 17:03:25 +00:00
ScalarEvolutionAliasAnalysis.cpp Make DataLayout Non-Optional in the Module 2015-03-04 18:43:29 +00:00
ScalarEvolutionExpander.cpp [SCEV] Strengthen SCEVExpander::isHighCostExpansion. 2015-04-14 03:20:32 +00:00
ScalarEvolutionNormalization.cpp Fix typos in comments, NFC 2014-08-29 21:53:01 +00:00
ScopedNoAliasAA.cpp Make DataLayout Non-Optional in the Module 2015-03-04 18:43:29 +00:00
SparsePropagation.cpp [Modules] Fix potential ODR violations by sinking the DEBUG_TYPE 2014-04-22 02:48:03 +00:00
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
TargetLibraryInfo.cpp Populate list of vectorizable functions for Accelerate library. 2015-05-07 17:11:51 +00:00
TargetTransformInfo.cpp [X86] Disable loop unrolling in loop vectorization pass when VF is 1. 2015-05-06 17:12:25 +00:00
Trace.cpp Put the functionality for printing a value to a raw_ostream as an 2014-01-09 02:29:41 +00:00
TypeBasedAliasAnalysis.cpp Teach TBAA analysis to report errors on cyclic TBAA metadata rather than hanging. 2015-03-13 07:09:33 +00:00
ValueTracking.cpp Reapply r237539 with a fix for the Chromium build. 2015-05-20 18:41:25 +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))

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