Skip to content

Commit 725400f

Browse files
committed
[NFCI][SimpleLoopUnswitch] Adjust CostKind query
When getUserCost was transitioned to use an explicit CostKind, TCK_CodeSize was used even though the original kind was implicitly SizeAndLatency so restore this behaviour. We now only query for CodeSize when optimising for minsize. I expect this to not change anything as, I think all, targets will currently return the same value for CodeSize and SizeLatency. Indeed I see no changes in the test suite for Arm, AArch64 and X86. Differential Revision: https://reviews.llvm.org/D85829
1 parent 95fad44 commit 725400f

File tree

3 files changed

+730
-1
lines changed

3 files changed

+730
-1
lines changed

llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2692,6 +2692,10 @@ unswitchBestCondition(Loop &L, DominatorTree &DT, LoopInfo &LI,
26922692
// (convergent, noduplicate, or cross-basic-block tokens).
26932693
// FIXME: We might be able to safely handle some of these in non-duplicated
26942694
// regions.
2695+
TargetTransformInfo::TargetCostKind CostKind =
2696+
L.getHeader()->getParent()->hasMinSize()
2697+
? TargetTransformInfo::TCK_CodeSize
2698+
: TargetTransformInfo::TCK_SizeAndLatency;
26952699
int LoopCost = 0;
26962700
for (auto *BB : L.blocks()) {
26972701
int Cost = 0;
@@ -2705,7 +2709,7 @@ unswitchBestCondition(Loop &L, DominatorTree &DT, LoopInfo &LI,
27052709
if (CB->isConvergent() || CB->cannotDuplicate())
27062710
return false;
27072711

2708-
Cost += TTI.getUserCost(&I, TargetTransformInfo::TCK_CodeSize);
2712+
Cost += TTI.getUserCost(&I, CostKind);
27092713
}
27102714
assert(Cost >= 0 && "Must not have negative costs!");
27112715
LoopCost += Cost;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
if not 'ARM' in config.root.targets:
2+
config.unsupported = True

0 commit comments

Comments
 (0)