llvm-project/llvm/lib/Analysis
Max Kazantsev fc539b0004 [SCEV] Infer ranges for SCC consisting of cycled Phis
Our current strategy of computing ranges of SCEVUnknown Phis was to simply
compute the union of ranges of all its inputs. In order to avoid infinite recursion,
we mark Phis as pending and conservatively return full set for them. As result,
even simplest patterns of cycled phis always have a range of full set.

This patch makes this logic a bit smarter. We basically do the same, but instead
of taking inputs of single Phi we find its strongly connected component (SCC)
and compute the union of all inputs that come into this SCC from outside.

Processing entire SCC together has one more advantage: we can set range for all
of them at once, because the only thing that happens to them is the same value is
being passed between those Phis. So, despite we spend more time analyzing a
single Phi, overall we may save time by not processing other SCC members, so
amortized compile time spent should be approximately the same.

Differential Revision: https://reviews.llvm.org/D110620
Reviewed By: reames
2022-02-17 18:03:52 +07:00
..
models [MLGO] ML Regalloc Eviction Advisor 2022-01-19 11:00:32 -08:00
AliasAnalysis.cpp [LICM] Generalize unwinding check during scalar promotion 2022-01-26 11:15:03 +01:00
AliasAnalysisEvaluator.cpp [NFC] Remove uses of PointerType::getElementType() 2022-01-25 09:44:52 +01:00
AliasAnalysisSummary.cpp
AliasAnalysisSummary.h
AliasSetTracker.cpp
Analysis.cpp Reapply CycleInfo: Introduce cycles as a generalization of loops 2021-12-10 14:36:43 +05:30
AssumeBundleQueries.cpp Make various assume bundle data structures use uint64_t 2021-10-13 10:38:41 -07:00
AssumptionCache.cpp [InferAddressSpaces] Support assumed addrspaces from addrspace predicates. 2021-11-08 16:51:57 -05:00
BasicAliasAnalysis.cpp [BasicAA] Add support for memmove intrinsic 2022-01-28 18:19:36 +07:00
BlockFrequencyInfo.cpp Internalize some cl::opt global variables or move them under namespace llvm 2021-05-07 11:15:43 -07:00
BlockFrequencyInfoImpl.cpp [NFC] Use Optional<ProfileCount> to model invalid counts 2021-11-14 19:03:30 -08:00
BranchProbabilityInfo.cpp [NFC] Add missing <map> includes 2022-01-19 12:29:03 +01:00
CFG.cpp [CFG] Move reachable from entry checks into basic block variant 2021-05-15 15:42:02 +02:00
CFGPrinter.cpp Use `-cfg-func-name` value as filter for `-view-cfg`, etc. 2021-06-16 23:54:51 +02:00
CFLAndersAliasAnalysis.cpp
CFLGraph.h
CFLSteensAliasAnalysis.cpp [llvm] Remove redundant member initialization (NFC) 2022-01-07 17:45:09 -08:00
CGSCCPassManager.cpp [NewPM] Add option to prevent rerunning function pipeline on functions in CGSCC adaptor 2021-11-17 09:06:46 -08:00
CMakeLists.txt [NFC][mlgo]Make the test model generator inlining-specific 2021-12-22 13:38:45 -08:00
CallGraph.cpp
CallGraphSCCPass.cpp [llvm] Remove redundant member initialization (NFC) 2022-01-07 17:45:09 -08:00
CallPrinter.cpp Revert "[NFC] Remove LinkAll*.h" 2021-11-02 09:08:09 -07:00
CaptureTracking.cpp [llvm] Use = default (NFC) 2022-02-06 22:18:35 -08:00
CmpInstAnalysis.cpp [APInt] Stop using soft-deprecated constructors and methods in llvm. NFC. 2021-10-04 08:57:44 +01:00
CodeMetrics.cpp [CodeMetrics] Don't require speculatability for ephemeral values 2021-10-21 20:30:01 +02:00
ConstantFolding.cpp [Analysis] propagate poison through add/sub saturate intrinsics 2022-02-15 10:45:32 -05:00
ConstraintSystem.cpp [ConstraintSystem] Mark function as const (NFC). 2022-01-27 13:44:47 +00:00
CostModel.cpp [Analysis] Use default member initialization (NFC) 2022-01-23 20:32:56 -08:00
CycleAnalysis.cpp Reapply CycleInfo: Introduce cycles as a generalization of loops 2021-12-10 14:36:43 +05:30
DDG.cpp [llvm] Use = default (NFC) 2022-02-06 22:18:35 -08:00
DDGPrinter.cpp Support: Stop using F_{None,Text,Append} compatibility synonyms, NFC 2021-04-30 11:00:03 -07:00
Delinearization.cpp [SCEV] Move getIndexExpressionsFromGEP to delinearize [NFC] 2021-09-08 16:56:49 -07:00
DemandedBits.cpp [APInt] Normalize naming on keep constructors / predicate methods. 2021-09-09 09:50:24 -07:00
DependenceAnalysis.cpp [APInt] Normalize naming on keep constructors / predicate methods. 2021-09-09 09:50:24 -07:00
DependenceGraphBuilder.cpp [NFC] Remove unnecessary #includes 2022-02-04 21:22:41 -08:00
DevelopmentModeInlineAdvisor.cpp [llvm] Remove uses of `std::vector<bool>` 2022-01-18 18:20:45 +01:00
DivergenceAnalysis.cpp [Analysis] Use default member initialization (NFC) 2022-01-23 20:32:56 -08:00
DomPrinter.cpp Introduce NewPM .dot printers for DomTree 2022-01-05 23:25:40 +00:00
DomTreeUpdater.cpp
DominanceFrontier.cpp [llvm] Remove redundant member initialization (NFC) 2022-01-07 17:45:09 -08:00
EHPersonalities.cpp [XCOFF] Handle the case when personality routine is an alias 2021-04-29 22:03:30 +00:00
FunctionPropertiesAnalysis.cpp
GlobalsModRef.cpp [llvm] Use = default (NFC) 2022-02-06 22:18:35 -08:00
GuardUtils.cpp
HeatUtils.cpp [llvm][clang][NFC] updates inline licence info 2021-08-11 02:48:53 +00:00
IRSimilarityIdentifier.cpp [IRSim] Make sure that commutative intrinsics are treated as function calls without commutativity 2022-02-02 13:24:56 -06:00
IVDescriptors.cpp [IVDescriptors] Support FOR where we have multiple sink pointed 2022-02-14 09:30:35 +08:00
IVUsers.cpp [llvm] Remove redundant member initialization (NFC) 2022-01-07 17:45:09 -08:00
ImportedFunctionsInliningStatistics.cpp [Analysis] ImportedFunctionsInliningStatistics.h - add <memory> and remove unused <string> include. NFCI. 2021-04-19 16:20:56 +01:00
IndirectCallPromotionAnalysis.cpp
InlineAdvisor.cpp [MLGO] Improved support for AOT cross-targeting scenarios 2022-01-20 07:05:39 -08:00
InlineCost.cpp [Inliner] Respect noinline call site attribute 2022-02-14 18:35:52 +01:00
InlineSizeEstimatorAnalysis.cpp [llvm] Use = default (NFC) 2022-02-06 22:18:35 -08:00
InstCount.cpp
InstructionPrecedenceTracking.cpp Revert "[IPT] Restructure cache to allow lazy update following invalidation [NFC]" 2021-10-21 10:48:41 -07:00
InstructionSimplify.cpp [InstSimplify] Delay creation of constants for offsets (NFC) 2022-02-17 09:56:32 +01:00
Interval.cpp
IntervalPartition.cpp [llvm] Use range-based for loops (NFC) 2021-11-20 18:42:10 -08:00
LazyBlockFrequencyInfo.cpp Make dependency between certain analysis passes transitive (reapply) 2021-05-05 15:17:55 +02:00
LazyBranchProbabilityInfo.cpp Make dependency between certain analysis passes transitive (reapply) 2021-05-05 15:17:55 +02:00
LazyCallGraph.cpp [Inliner] Don't removeDeadConstantUsers() when checking if a function is dead 2022-01-13 14:29:45 -08:00
LazyValueInfo.cpp [LVI] Handle implication from icmp of trunc (PR51867) 2022-01-18 11:24:11 +01:00
LegacyDivergenceAnalysis.cpp [NFC] Remove unnecessary #includes 2022-02-04 21:22:41 -08:00
Lint.cpp Put implementation details into anonymous namespaces. NFCI. 2021-11-07 15:18:30 +01:00
Loads.cpp [Loads] Require Align in isDereferenceableAndAlignedPointer() (NFC) 2022-01-28 16:23:32 +01:00
LoopAccessAnalysis.cpp [PSE] Remove assumption that top level predicate is union from public interface [NFC*] 2022-02-10 16:14:52 -08:00
LoopAnalysisManager.cpp [NewPM] Don't mark AA analyses as preserved 2021-05-18 13:49:03 -07:00
LoopCacheAnalysis.cpp [llvm] Remove redundant member initialization (NFC) 2022-01-07 17:45:09 -08:00
LoopInfo.cpp [ScalarEvolution] Mark a loop as finite if in a willreturn function 2022-01-28 14:17:05 -05:00
LoopNestAnalysis.cpp LoopNest Analysis expansion to return instructions that prevent a Loop 2021-08-17 22:25:49 +00:00
LoopPass.cpp [llvm] Remove redundant member initialization (NFC) 2022-01-07 17:45:09 -08:00
LoopUnrollAnalyzer.cpp [unroll] Use value domain for symbolic execution based cost model 2021-05-26 08:41:25 -07:00
MLInlineAdvisor.cpp [NFC][MLGO] Simplify conditional compilation 2022-01-24 11:19:04 -08:00
MemDepPrinter.cpp
MemDerefPrinter.cpp [Loads] Require Align in isDereferenceableAndAlignedPointer() (NFC) 2022-01-28 16:23:32 +01:00
MemoryBuiltins.cpp [MemoryBuiltins][FIX] Adjust index type size properly wrt. AS casts 2022-02-07 20:19:19 -06:00
MemoryDependenceAnalysis.cpp [MemoryDependency] Relax the re-ordering of atomic store and unordered load/store 2022-02-17 10:53:25 +07:00
MemoryLocation.cpp [DSE][MemLoc] Handle intrinsics more generically 2021-12-24 09:29:57 +01:00
MemorySSA.cpp [llvm] Use = default (NFC) 2022-02-06 22:18:35 -08:00
MemorySSAUpdater.cpp [llvm] Use range-based for loops (NFC) 2021-11-18 09:09:52 -08:00
ModelUnderTrainingRunner.cpp [NFC][MLGO] Remove the word "inliner" in a generic error message. 2022-01-11 12:39:16 -08:00
ModuleDebugInfoPrinter.cpp Reduce dependencies on llvm/BinaryFormat/Dwarf.h 2022-02-04 11:44:03 +01:00
ModuleSummaryAnalysis.cpp [LTO][WPD] Simplify mustBeUnreachableFunction and test after D115492 2021-12-15 15:43:35 -08:00
MustExecute.cpp
NoInferenceModelRunner.cpp [NFC][MLGO]Add RTTI support for MLModelRunner and simplify runner setup 2022-01-04 19:46:14 -08:00
ObjCARCAliasAnalysis.cpp
ObjCARCAnalysisUtils.cpp
ObjCARCInstKind.cpp [ObjCARC] Use "UnsafeClaimRV" to refer to unsafeClaim in enums. NFC. 2022-01-24 19:37:01 -08:00
OptimizationRemarkEmitter.cpp
OverflowInstAnalysis.cpp Ensure newlines at the end of files (NFC) 2021-10-23 08:45:29 -07:00
PHITransAddr.cpp [PHITransAddr] Check GEP source element type 2022-02-11 16:22:48 +01:00
PhiValues.cpp
PostDominators.cpp
ProfileSummaryInfo.cpp [NFC] Use Optional<ProfileCount> to model invalid counts 2021-11-14 19:03:30 -08:00
PtrUseVisitor.cpp
README.txt
RegionInfo.cpp [NFC] Remove unnecessary #includes 2022-02-04 21:22:41 -08:00
RegionPass.cpp [NFC] Remove unnecessary #includes 2022-02-04 21:22:41 -08:00
RegionPrinter.cpp
ReplayInlineAdvisor.cpp [Analysis] Use default member initialization (NFC) 2022-01-23 20:32:56 -08:00
ScalarEvolution.cpp [SCEV] Infer ranges for SCC consisting of cycled Phis 2022-02-17 18:03:52 +07:00
ScalarEvolutionAliasAnalysis.cpp [SCEVAA] Avoid forming malformed pointer diff expressions 2021-11-17 12:38:04 -08:00
ScalarEvolutionDivision.cpp
ScalarEvolutionNormalization.cpp
ScopedNoAliasAA.cpp
StackLifetime.cpp [NPM] Added -print-pipeline-passes print params for a few passes. 2021-09-15 08:34:04 +02:00
StackSafetyAnalysis.cpp [stack-safety] Check SCEV constraints at memory instructions. 2021-11-23 15:29:23 -08:00
StratifiedSets.h
SyncDependenceAnalysis.cpp [llvm] Use = default (NFC) 2022-02-06 22:18:35 -08:00
SyntheticCountsUtils.cpp
TFUtils.cpp [MLGO] Add support for multiple training traces per module 2022-01-11 16:13:31 -08:00
TargetLibraryInfo.cpp Revert "Revert "Use VersionTuple for parsing versions in Triple, fixing issues that caused the original change to be reverted. This makes it possible to distinguish between "16" and "16.0" after parsing, which previously was not possible."" 2021-12-07 23:15:21 +00:00
TargetTransformInfo.cpp [llvm] Use = default (NFC) 2022-02-06 22:18:35 -08:00
Trace.cpp
TypeBasedAliasAnalysis.cpp [LoopIdiom] Keep TBAA when creating memcpy/memmove 2022-01-31 16:28:13 -05:00
TypeMetadataUtils.cpp [GlobalDCE] In VFE, replace the whole 'sub' expression of unused relative-pointer-based vtable slots 2021-10-06 15:55:55 -07:00
VFABIDemangling.cpp [LLVM][NFC]Inclusive language: remove occurances of sanity check/test from llvm 2021-11-24 17:29:55 -05:00
ValueLattice.cpp
ValueLatticeUtils.cpp [SCCP] Check that load/store and global type match 2022-02-11 11:01:18 +01:00
ValueTracking.cpp [ValueTracking] Checking haveNoCommonBitsSet for (x & y) and ~(x | y) 2022-02-16 13:42:52 +08:00
VectorUtils.cpp [Analysis] add utility function for unary shuffle mask creation 2021-10-18 09:00:39 -04: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))

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