mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 11:13:28 +01:00
93f61e6588
Summary: The motivation example is like below which has 13 cases but only 2 distinct targets ``` lor.lhs.false2: ; preds = %if.then switch i32 %Status, label %if.then27 [ i32 -7012, label %if.end35 i32 -10008, label %if.end35 i32 -10016, label %if.end35 i32 15000, label %if.end35 i32 14013, label %if.end35 i32 10114, label %if.end35 i32 10107, label %if.end35 i32 10105, label %if.end35 i32 10013, label %if.end35 i32 10011, label %if.end35 i32 7008, label %if.end35 i32 7007, label %if.end35 i32 5002, label %if.end35 ] ``` which is compiled into a balanced binary tree like this on AArch64 (similar on X86) ``` .LBB853_9: // %lor.lhs.false2 mov w8, #10012 cmp w19, w8 b.gt .LBB853_14 // BB#10: // %lor.lhs.false2 mov w8, #5001 cmp w19, w8 b.gt .LBB853_18 // BB#11: // %lor.lhs.false2 mov w8, #-10016 cmp w19, w8 b.eq .LBB853_23 // BB#12: // %lor.lhs.false2 mov w8, #-10008 cmp w19, w8 b.eq .LBB853_23 // BB#13: // %lor.lhs.false2 mov w8, #-7012 cmp w19, w8 b.eq .LBB853_23 b .LBB853_3 .LBB853_14: // %lor.lhs.false2 mov w8, #14012 cmp w19, w8 b.gt .LBB853_21 // BB#15: // %lor.lhs.false2 mov w8, #-10105 add w8, w19, w8 cmp w8, #9 // =9 b.hi .LBB853_17 // BB#16: // %lor.lhs.false2 orr w9, wzr, #0x1 lsl w8, w9, w8 mov w9, #517 and w8, w8, w9 cbnz w8, .LBB853_23 .LBB853_17: // %lor.lhs.false2 mov w8, #10013 cmp w19, w8 b.eq .LBB853_23 b .LBB853_3 .LBB853_18: // %lor.lhs.false2 mov w8, #-7007 add w8, w19, w8 cmp w8, #2 // =2 b.lo .LBB853_23 // BB#19: // %lor.lhs.false2 mov w8, #5002 cmp w19, w8 b.eq .LBB853_23 // BB#20: // %lor.lhs.false2 mov w8, #10011 cmp w19, w8 b.eq .LBB853_23 b .LBB853_3 .LBB853_21: // %lor.lhs.false2 mov w8, #14013 cmp w19, w8 b.eq .LBB853_23 // BB#22: // %lor.lhs.false2 mov w8, #15000 cmp w19, w8 b.ne .LBB853_3 ``` However, the inline cost model estimates the cost to be linear with the number of distinct targets and the cost of the above switch is just 2 InstrCosts. The function containing this switch is then inlined about 900 times. This change use the general way of switch lowering for the inline heuristic. It etimate the number of case clusters with the suitability check for a jump table or bit test. Considering the binary search tree built for the clusters, this change modifies the model to be linear with the size of the balanced binary tree. The model is off by default for now : -inline-generic-switch-cost=false This change was originally proposed by Haicheng in D29870. Reviewers: hans, bmakam, chandlerc, eraman, haicheng, mcrosier Reviewed By: hans Subscribers: joerg, aemerson, llvm-commits, rengolin Differential Revision: https://reviews.llvm.org/D31085 llvm-svn: 301649 |
||
---|---|---|
.. | ||
AliasAnalysis.h | ||
AliasAnalysisEvaluator.h | ||
AliasSetTracker.h | ||
AssumptionCache.h | ||
BasicAliasAnalysis.h | ||
BlockFrequencyInfo.h | ||
BlockFrequencyInfoImpl.h | ||
BranchProbabilityInfo.h | ||
CallGraph.h | ||
CallGraphSCCPass.h | ||
CallPrinter.h | ||
CaptureTracking.h | ||
CFG.h | ||
CFGPrinter.h | ||
CFLAndersAliasAnalysis.h | ||
CFLSteensAliasAnalysis.h | ||
CGSCCPassManager.h | ||
CodeMetrics.h | ||
ConstantFolding.h | ||
DemandedBits.h | ||
DependenceAnalysis.h | ||
DivergenceAnalysis.h | ||
DominanceFrontier.h | ||
DominanceFrontierImpl.h | ||
DomPrinter.h | ||
DOTGraphTraitsPass.h | ||
EHPersonalities.h | ||
GlobalsModRef.h | ||
IndirectCallPromotionAnalysis.h | ||
IndirectCallSiteVisitor.h | ||
InlineCost.h | ||
InstructionSimplify.h | ||
Interval.h | ||
IntervalIterator.h | ||
IntervalPartition.h | ||
IteratedDominanceFrontier.h | ||
IVUsers.h | ||
LazyBlockFrequencyInfo.h | ||
LazyBranchProbabilityInfo.h | ||
LazyCallGraph.h | ||
LazyValueInfo.h | ||
Lint.h | ||
Loads.h | ||
LoopAccessAnalysis.h | ||
LoopAnalysisManager.h | ||
LoopInfo.h | ||
LoopInfoImpl.h | ||
LoopIterator.h | ||
LoopPass.h | ||
LoopUnrollAnalyzer.h | ||
MemoryBuiltins.h | ||
MemoryDependenceAnalysis.h | ||
MemoryLocation.h | ||
MemorySSA.h | ||
MemorySSAUpdater.h | ||
ModuleSummaryAnalysis.h | ||
ObjCARCAliasAnalysis.h | ||
ObjCARCAnalysisUtils.h | ||
ObjCARCInstKind.h | ||
ObjectUtils.h | ||
OptimizationDiagnosticInfo.h | ||
OrderedBasicBlock.h | ||
Passes.h | ||
PHITransAddr.h | ||
PostDominators.h | ||
ProfileSummaryInfo.h | ||
PtrUseVisitor.h | ||
RegionInfo.h | ||
RegionInfoImpl.h | ||
RegionIterator.h | ||
RegionPass.h | ||
RegionPrinter.h | ||
ScalarEvolution.h | ||
ScalarEvolutionAliasAnalysis.h | ||
ScalarEvolutionExpander.h | ||
ScalarEvolutionExpressions.h | ||
ScalarEvolutionNormalization.h | ||
ScopedNoAliasAA.h | ||
SparsePropagation.h | ||
TargetFolder.h | ||
TargetLibraryInfo.def | ||
TargetLibraryInfo.h | ||
TargetTransformInfo.h | ||
TargetTransformInfoImpl.h | ||
Trace.h | ||
TypeBasedAliasAnalysis.h | ||
TypeMetadataUtils.h | ||
ValueTracking.h | ||
VectorUtils.h |