hanchenye-llvm-project/llvm/lib/Analysis
Amara Emerson 146882242f [GlobalISel][Localizer] Rewrite localizer to run in 2 phases, inter & intra block.
Inter-block localization is the same as what currently happens, except now it
only runs on the entry block because that's where the problematic constants with
long live ranges come from.

The second phase is a new intra-block localization phase which attempts to
re-sink the already localized instructions further right before one of the
multiple uses.

One additional change is to also localize G_GLOBAL_VALUE as they're constants
too. However, on some targets like arm64 it takes multiple instructions to
materialize the value, so some additional heuristics with a TTI hook have been
introduced attempt to prevent code size regressions when localizing these.

Overall, these changes improve CTMark code size on arm64 by 1.2%.

Full code size results:

Program                                         baseline       new       diff
------------------------------------------------------------------------------
 test-suite...-typeset/consumer-typeset.test    1249984      1217216     -2.6%
 test-suite...:: CTMark/ClamAV/clamscan.test    1264928      1232152     -2.6%
 test-suite :: CTMark/SPASS/SPASS.test          1394092      1361316     -2.4%
 test-suite...Mark/mafft/pairlocalalign.test    731320       714928      -2.2%
 test-suite :: CTMark/lencod/lencod.test        1340592      1324200     -1.2%
 test-suite :: CTMark/kimwitu++/kc.test         3853512      3820420     -0.9%
 test-suite :: CTMark/Bullet/bullet.test        3406036      3389652     -0.5%
 test-suite...ark/tramp3d-v4/tramp3d-v4.test    8017000      8016992     -0.0%
 test-suite...TMark/7zip/7zip-benchmark.test    2856588      2856588      0.0%
 test-suite...:: CTMark/sqlite3/sqlite3.test    765704       765704       0.0%
 Geomean difference                                                      -1.2%

Differential Revision: https://reviews.llvm.org/D63303

llvm-svn: 363632
2019-06-17 23:20:29 +00:00
..
AliasAnalysis.cpp [AliasAnalysis/NewPassManager] Invalidate AAManager less often. 2019-04-30 22:15:47 +00:00
AliasAnalysisEvaluator.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
AliasAnalysisSummary.cpp Move CFLGraph and the AA summary code over to the new `CallBase` 2019-02-11 09:25:41 +00:00
AliasAnalysisSummary.h Move CFLGraph and the AA summary code over to the new `CallBase` 2019-02-11 09:25:41 +00:00
AliasSetTracker.cpp [LICM/MSSA] Add promotion to scalars by building an AliasSetTracker with MemorySSA. 2019-02-06 20:25:17 +00:00
Analysis.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
AssumptionCache.cpp [CodeExtractor] Update function's assumption cache after extracting blocks from it 2019-02-08 06:55:18 +00:00
BasicAliasAnalysis.cpp Add an optional list of blocks to avoid when looking for a path in isPotentiallyReachable. 2019-04-02 01:05:48 +00:00
BlockFrequencyInfo.cpp Add optional arg to profile count getters to filter 2019-04-24 19:51:16 +00:00
BlockFrequencyInfoImpl.cpp Add optional arg to profile count getters to filter 2019-04-24 19:51:16 +00:00
BranchProbabilityInfo.cpp [BPI] Look through bitcasts in calcZeroHeuristic 2019-02-15 11:50:21 +00:00
CFG.cpp An unreachable block may have a route to a reachable block, don't fast-path return that it can't. 2019-04-04 23:09:40 +00:00
CFGPrinter.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
CFLAndersAliasAnalysis.cpp [AliasAnalysis] Second prototype to cache BasicAA / anyAA state. 2019-03-22 17:22:19 +00:00
CFLGraph.h [CFLGraph] Add support for unary fneg instruction. 2019-06-06 19:21:23 +00:00
CFLSteensAliasAnalysis.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
CGSCCPassManager.cpp [NewPM] Fix a nasty bug with analysis invalidation in the new PM. 2019-03-28 00:51:36 +00:00
CMakeLists.txt Move DomTreeUpdater from IR to Analysis 2019-02-06 02:52:52 +00:00
CallGraph.cpp [CallSite removal] Move the legacy PM, call graph, and some inliner 2019-04-19 05:59:42 +00:00
CallGraphSCCPass.cpp [CallSite removal] Move the legacy PM, call graph, and some inliner 2019-04-19 05:59:42 +00:00
CallPrinter.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
CaptureTracking.cpp [CaptureTracking] Don't let comparisons against null escape inbounds pointers 2019-06-09 10:20:33 +00:00
CmpInstAnalysis.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
CodeMetrics.cpp Remove `CallSite` from the CodeMetrics analysis, moving it to the new 2019-02-11 09:03:32 +00:00
ConstantFolding.cpp [NFC] Don't export helpers of ConstantFoldCall 2019-06-07 13:28:52 +00:00
CostModel.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
Delinearization.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
DemandedBits.cpp [DemandedBits] Remove some redundancy in the work list 2019-03-03 14:50:01 +00:00
DependenceAnalysis.cpp [DA] Add an option to control delinearization validity checks 2019-06-06 15:12:49 +00:00
DivergenceAnalysis.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
DomPrinter.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
DomTreeUpdater.cpp [DTU] Refine the interface and logic of applyUpdates 2019-02-22 13:48:38 +00:00
DominanceFrontier.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
EHPersonalities.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
GlobalsModRef.cpp Add "const" in GetUnderlyingObjects. NFC 2019-04-24 06:55:50 +00:00
GuardUtils.cpp [WideableCond] Fix a nasty bug in detection of "explicit guards" 2019-04-02 16:51:43 +00:00
IVDescriptors.cpp Save the induction binary operator in IVDescriptors for non FP induction variables. 2019-05-14 13:26:36 +00:00
IVUsers.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
IndirectCallPromotionAnalysis.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
InlineCost.cpp [InlineCost] Add support for unary fneg. 2019-06-06 19:02:18 +00:00
InstCount.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
InstructionPrecedenceTracking.cpp Make widenable condition transparent for MemoryWriteTracking 2019-02-14 11:10:29 +00:00
InstructionSimplify.cpp [InstSimplify] Fix addo/subo undef folds (PR42209) 2019-06-16 20:39:45 +00:00
Interval.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
IntervalPartition.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
IteratedDominanceFrontier.cpp [IDF] Delete a redundant J-edge test 2019-03-07 11:42:59 +00:00
LLVMBuild.txt Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
LazyBlockFrequencyInfo.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
LazyBranchProbabilityInfo.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
LazyCallGraph.cpp [LCG] Add aliased functions as LCG roots 2019-04-05 18:51:08 +00:00
LazyValueInfo.cpp Introduce Value::stripPointerCastsSameRepresentation 2019-06-04 20:21:46 +00:00
LegacyDivergenceAnalysis.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
Lint.cpp [Lint] Permit aliasing noalias readonly arguments 2019-04-23 23:43:47 +00:00
Loads.cpp [Analysis] Fix isSafeToLoadUnconditionally handling of volatile. 2019-01-24 21:31:13 +00:00
LoopAccessAnalysis.cpp LoopDistribute/LAA: Respect convergent 2019-06-12 13:34:19 +00:00
LoopAnalysisManager.cpp Only passes that preserve MemorySSA must mark it as preserved. 2019-06-11 18:27:49 +00:00
LoopInfo.cpp [LOOPINFO] Extend Loop object to add utilities to get the loop bounds, 2019-06-05 20:42:47 +00:00
LoopPass.cpp ftime-trace: Trace loop passes 2019-05-31 10:14:04 +00:00
LoopUnrollAnalyzer.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
MemDepPrinter.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
MemDerefPrinter.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
MemoryBuiltins.cpp Fix a hang when lowering __builtin_dynamic_object_size 2019-04-10 23:42:11 +00:00
MemoryDependenceAnalysis.cpp [MemDepAnalysis] Allow caller to pass in an OrderedBasicBlock. 2019-03-28 19:17:31 +00:00
MemoryLocation.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
MemorySSA.cpp [MemorySSA] Check that block is reachable when adding phis. 2019-05-02 23:41:58 +00:00
MemorySSAUpdater.cpp [MemorySSA] Don't use template when the clone is a simplified instruction. 2019-06-17 18:58:40 +00:00
ModuleDebugInfoPrinter.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ModuleSummaryAnalysis.cpp [ThinLTO] Auto-hide prevailing linkonce_odr only when all copies eligible 2019-05-10 20:08:24 +00:00
MustExecute.cpp [MustExecute] Improve MustExecute to correctly handle loop nest 2019-05-27 13:57:28 +00:00
ObjCARCAliasAnalysis.cpp [AliasAnalysis] Second prototype to cache BasicAA / anyAA state. 2019-03-22 17:22:19 +00:00
ObjCARCAnalysisUtils.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ObjCARCInstKind.cpp [ObjC][ARC] Delete ObjC runtime calls on global variables annotated 2019-06-14 22:06:32 +00:00
OptimizationRemarkEmitter.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
OrderedBasicBlock.cpp Recommit "[DSE] Preserve basic block ordering using OrderedBasicBlock." 2019-03-29 14:10:24 +00:00
OrderedInstructions.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
PHITransAddr.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
PhiValues.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
PostDominators.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ProfileSummaryInfo.cpp Add optional arg to profile count getters to filter 2019-04-24 19:51:16 +00:00
PtrUseVisitor.cpp SROA: Allow eliminating addrspacecasted allocas 2019-06-14 21:38:31 +00:00
README.txt
RegionInfo.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
RegionPass.cpp [IR] Refactor attribute methods in Function class (NFC) 2019-04-04 22:40:06 +00:00
RegionPrinter.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ScalarEvolution.cpp Teach getSCEVAtScope how to handle loop phis w/invariant operands in loops w/taken backedges 2019-06-17 21:06:17 +00:00
ScalarEvolutionAliasAnalysis.cpp [AliasAnalysis] Second prototype to cache BasicAA / anyAA state. 2019-03-22 17:22:19 +00:00
ScalarEvolutionExpander.cpp [SCEV] Use NoWrapFlags when expanding a simple mul 2019-06-17 10:05:18 +00:00
ScalarEvolutionNormalization.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ScopedNoAliasAA.cpp [AliasAnalysis] Second prototype to cache BasicAA / anyAA state. 2019-03-22 17:22:19 +00:00
StackSafetyAnalysis.cpp Hide two unused debugging methods, NFCI. 2019-03-01 17:15:21 +00:00
StratifiedSets.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
SyncDependenceAnalysis.cpp [SDA] Bug fix: Use IPD outside the loop as divergence bound 2019-04-18 16:17:35 +00:00
SyntheticCountsUtils.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
TargetLibraryInfo.cpp Initial support for IBM MASS vector library 2019-06-05 01:31:43 +00:00
TargetTransformInfo.cpp [GlobalISel][Localizer] Rewrite localizer to run in 2 phases, inter & intra block. 2019-06-17 23:20:29 +00:00
Trace.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
TypeBasedAliasAnalysis.cpp [AliasAnalysis] Second prototype to cache BasicAA / anyAA state. 2019-03-22 17:22:19 +00:00
TypeMetadataUtils.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ValueLattice.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ValueLatticeUtils.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ValueTracking.cpp [LangRef] Clarify poison semantics 2019-06-13 19:45:36 +00:00
VectorUtils.cpp [Analysis] add isSplatValue() for vectors in IR 2019-06-11 22:25:18 +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))

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