1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 11:42:57 +01:00
llvm-mirror/lib/Analysis
David Green 49873f2449 [Analysis] TTI: Add CastContextHint for getCastInstrCost
Currently, getCastInstrCost has limited information about the cast it's
rating, often just the opcode and types.  Sometimes there is a context
instruction as well, but it isn't trustworthy: for instance, when the
vectorizer is rating a plan, it calls getCastInstrCost with the old
instructions when, in fact, it's trying to evaluate the cost of the
instruction post-vectorization.  Thus, the current system can get the
cost of certain casts incorrect as the correct cost can vary greatly
based on the context in which it's used.

For example, if the vectorizer queries getCastInstrCost to evaluate the
cost of a sext(load) with tail predication enabled, getCastInstrCost
will think it's free most of the time, but it's not always free. On ARM
MVE, a VLD2 group cannot be extended like a normal VLDR can. Similar
situations can come up with how masked loads can be extended when being
split.

To fix that, this path adds a new parameter to getCastInstrCost to give
it a hint about the context of the cast. It adds a CastContextHint enum
which contains the type of the load/store being created by the
vectorizer - one for each of the types it can produce.

Original patch by Pierre van Houtryve

Differential Revision: https://reviews.llvm.org/D79162
2020-07-29 13:32:53 +01:00
..
models/inliner [llvm][NFC] ML Policies: changed the saved_model protobuf to text 2020-07-13 11:07:07 -07:00
AliasAnalysis.cpp [BasicAA] Rename -disable-basicaa to -disable-basic-aa to be consistent with the canonical name "basic-aa" 2020-06-26 20:55:44 -07:00
AliasAnalysisEvaluator.cpp
AliasAnalysisSummary.cpp
AliasAnalysisSummary.h
AliasSetTracker.cpp
Analysis.cpp
AssumeBundleQueries.cpp Temporarily Revert "[AssumeBundles] Use operand bundles to encode alignment assumptions" 2020-07-16 11:54:04 -07:00
AssumptionCache.cpp Use llvm::is_contained where appropriate (NFC) 2020-07-27 10:20:44 -07:00
BasicAliasAnalysis.cpp [BasicAA] Fix -basicaa-recphi for geps with negative offsets 2020-07-16 17:22:40 +01:00
BlockFrequencyInfo.cpp
BlockFrequencyInfoImpl.cpp
BranchProbabilityInfo.cpp [BPI] Fix memory leak reported by sanitizer bots 2020-07-28 19:53:46 +07:00
CallGraph.cpp [CallGraph] Preserve call records vector when replacing call edge 2020-07-27 06:02:55 -07:00
CallGraphSCCPass.cpp [CallGraph] Update callback call sites in RefreshCallGraph 2020-07-14 22:33:57 -05:00
CallPrinter.cpp Revert rG5dd566b7c7b78bd- "PassManager.h - remove unnecessary Function.h/Module.h includes. NFCI." 2020-07-24 13:02:33 +01:00
CaptureTracking.cpp [Analysis] Ensure we include CommandLine.h if we declare any cl::opt flags. NFC. 2020-06-23 12:29:51 +01:00
CFG.cpp
CFGPrinter.cpp
CFLAndersAliasAnalysis.cpp
CFLGraph.h
CFLSteensAliasAnalysis.cpp
CGSCCPassManager.cpp [NewPM] Move debugging log printing after PassInstrumentation before-pass-callbacks 2020-06-25 10:03:25 -07:00
CMakeLists.txt Reapply "Rename InlineFeatureAnalysis to FunctionPropertiesAnalysis" 2020-07-22 10:07:35 -07:00
CmpInstAnalysis.cpp
CodeMetrics.cpp
ConstantFolding.cpp [ConstantFolding] Fold freeze if it is never undef or poison 2020-07-26 21:54:44 +09:00
CostModel.cpp
DDG.cpp
Delinearization.cpp
DemandedBits.cpp
DependenceAnalysis.cpp
DependenceGraphBuilder.cpp
DevelopmentModeInlineAdvisor.cpp Build: Move TF source file inclusion from build system to source files 2020-07-21 13:02:34 -04:00
DivergenceAnalysis.cpp [DA] conservatively mark the join of every divergent branch 2020-06-18 17:39:20 +05:30
DominanceFrontier.cpp
DomPrinter.cpp
DomTreeUpdater.cpp [DomTreeUpdater] Use const auto * when iterating over pointers (NFC). 2020-07-10 16:39:15 +01:00
EHPersonalities.cpp
FunctionPropertiesAnalysis.cpp Use llvm::size rather than an empty loop to get the number of top 2020-07-23 14:55:50 -07:00
GlobalsModRef.cpp GlobalsModRef.h - reduce CallGraph.h include to forward declarations. NFC. 2020-06-25 16:00:43 +01:00
GuardUtils.cpp
HeatUtils.cpp [CallPrinter] Remove static constructor. 2020-06-17 13:02:58 +02:00
IndirectCallPromotionAnalysis.cpp
InlineAdvisor.cpp [llvm] Development-mode InlineAdvisor 2020-07-20 11:01:56 -07:00
InlineCost.cpp [InlineCost] GetElementPtr with constant operands 2020-06-25 18:09:51 +00:00
InlineSizeEstimatorAnalysis.cpp [llvm] Moved InlineSizeEstimatorAnalysis test to .ll 2020-07-16 12:25:16 -07:00
InstCount.cpp
InstructionPrecedenceTracking.cpp
InstructionSimplify.cpp [InstSimplify] allow undefs in icmp with vector constant folds 2020-07-28 15:13:53 -04:00
Interval.cpp
IntervalPartition.cpp
IVDescriptors.cpp
IVUsers.cpp
LazyBlockFrequencyInfo.cpp
LazyBranchProbabilityInfo.cpp
LazyCallGraph.cpp
LazyValueInfo.cpp [LVI] Don't require operand number for range (NFC) 2020-07-25 16:33:45 +02:00
LegacyDivergenceAnalysis.cpp
Lint.cpp [SVE] Remove calls to VectorType::getNumElements from Analysis 2020-07-22 15:19:05 -07:00
LLVMBuild.txt [llvm][NFC] Move content of ML subdirectory into Analysis 2020-06-15 14:35:33 -07:00
Loads.cpp [Analysis] isDereferenceableAndAlignedPointer(): don't crash on bitcast <1 x ???*> to ???* 2020-06-27 18:30:59 +03:00
LoopAccessAnalysis.cpp [LV] Vectorize without versioning-for-unit-stride under -Os/-Oz 2020-07-07 15:04:21 +03:00
LoopAnalysisManager.cpp
LoopCacheAnalysis.cpp
LoopInfo.cpp
LoopNestAnalysis.cpp
LoopPass.cpp Revert rG5dd566b7c7b78bd- "PassManager.h - remove unnecessary Function.h/Module.h includes. NFCI." 2020-07-24 13:02:33 +01:00
LoopUnrollAnalyzer.cpp ScalarEvolution.h - reduce LoopInfo.h include to forward declarations. NFC. 2020-06-17 15:48:23 +01:00
MemDepPrinter.cpp GVN.h - reduce AliasAnalysis.h include to forward declaration. NFC. 2020-06-25 16:59:35 +01:00
MemDerefPrinter.cpp Loads.h - reduce AliasAnalysis.h include to forward declarations. NFC. 2020-06-24 13:49:04 +01:00
MemoryBuiltins.cpp IR: Define byref parameter attribute 2020-07-20 10:23:09 -04:00
MemoryDependenceAnalysis.cpp [MemDep] Also remove load instructions from NonLocalDesCache. 2020-06-17 09:36:53 +01:00
MemoryLocation.cpp
MemorySSA.cpp
MemorySSAUpdater.cpp [GraphDiff] Use class method getChildren instead of GraphTraits. 2020-07-27 16:12:34 -07:00
MLInlineAdvisor.cpp Reapply "Rename InlineFeatureAnalysis to FunctionPropertiesAnalysis" 2020-07-22 10:07:35 -07:00
ModuleDebugInfoPrinter.cpp
ModuleSummaryAnalysis.cpp [StackSafety] Pass summary into codegen 2020-06-10 21:02:54 -07:00
MustExecute.cpp
ObjCARCAliasAnalysis.cpp
ObjCARCAnalysisUtils.cpp
ObjCARCInstKind.cpp [Analysis/Transforms/Sanitizers] As part of using inclusive language 2020-06-20 00:42:26 -07:00
OptimizationRemarkEmitter.cpp
PHITransAddr.cpp
PhiValues.cpp
PostDominators.cpp
ProfileSummaryInfo.cpp [NFC] Change getEntryForPercentile to be a static function in ProfileSummaryBuilder. 2020-07-09 16:38:19 -07:00
PtrUseVisitor.cpp
README.txt
RegionInfo.cpp RegionInfo.cpp - remove duplicate includes that already exist in RegionInfo.h. NFC. 2020-07-23 17:50:22 +01:00
RegionPass.cpp
RegionPrinter.cpp
ReleaseModeModelRunner.cpp Build: Move TF source file inclusion from build system to source files 2020-07-21 13:02:34 -04:00
ScalarEvolution.cpp [SCEV] Remove premature assert. PR46786 2020-07-22 15:43:16 +07:00
ScalarEvolutionAliasAnalysis.cpp
ScalarEvolutionDivision.cpp [NFCI] SCEV: promote ScalarEvolutionDivision into an publicly usable class 2020-06-25 00:58:53 +03:00
ScalarEvolutionNormalization.cpp
ScopedNoAliasAA.cpp Rename scoped-noalias -> scoped-noalias-aa 2020-07-24 12:14:27 -07:00
StackLifetime.cpp [StackSafety,NFC] Don't rerun on LiveIn change 2020-06-19 21:29:31 -07:00
StackSafetyAnalysis.cpp StackSafetyAnalysis.cpp - pass ConstantRange arg as const reference. 2020-07-10 12:13:34 +01:00
StratifiedSets.h
SyncDependenceAnalysis.cpp
SyntheticCountsUtils.cpp
TargetLibraryInfo.cpp [LLVM] Add libatomic load/store functions to TargetLibraryInfo 2020-07-18 03:18:48 +00:00
TargetTransformInfo.cpp [Analysis] TTI: Add CastContextHint for getCastInstrCost 2020-07-29 13:32:53 +01:00
TFUtils.cpp Build: Move TF source file inclusion from build system to source files 2020-07-21 13:02:34 -04:00
Trace.cpp
TypeBasedAliasAnalysis.cpp
TypeMetadataUtils.cpp
ValueLattice.cpp
ValueLatticeUtils.cpp [ValueLattice] Simplify canTrackGlobalVariableInterprocedurally (NFC). 2020-07-09 18:33:09 +01:00
ValueTracking.cpp [ValueTracking] Instruction::isBinaryOp should be used for constexprs 2020-07-26 21:48:51 +09:00
VectorUtils.cpp [SVE] Remove calls to VectorType::getNumElements from Analysis 2020-07-22 15:19:05 -07:00
VFABIDemangling.cpp

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

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