[all-commits] [llvm/llvm-project] d1b376: [FuncSpec] Rework the discardment logic for unprof...
Alexandros Lamprineas via All-commits
all-commits at lists.llvm.org
Wed Aug 9 02:33:19 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: d1b376fd7bf73bca557f3c174d4c129ed4d45ae5
https://github.com/llvm/llvm-project/commit/d1b376fd7bf73bca557f3c174d4c129ed4d45ae5
Author: Alexandros Lamprineas <alexandros.lamprineas at arm.com>
Date: 2023-08-09 (Wed, 09 Aug 2023)
Changed paths:
M llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h
M llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
M llvm/unittests/Transforms/IPO/FunctionSpecializationTest.cpp
Log Message:
-----------
[FuncSpec] Rework the discardment logic for unprofitable specializations.
Currently we make an arbitrary comparison between codesize and latency
in order to decide whether to keep a specialization or not. Sometimes
the latency savings are biased in favor of loops because of imprecise
block frequencies, therefore this metric contains a lot of noise. This
patch tries to address the problem as follows:
* Reject specializations whose codesize savings are less than X% of
the original function size.
* Reject specializations whose latency savings are less than Y% of
the original function size.
* Reject specializations whose inlining bonus is less than Z% of
the original function size.
I am not saying this is super precise, but at least X, Y and Z are
configurable, allowing us to tweak the cost model. Moreover, it lets
us prioritize codesize over latency, which is a less noisy metric.
I am also increasing the minimum size a function should have to be
considered a candidate for specialization. Initially the cost of
a function was calculated as
CodeMetrics::NumInsts * InlineConstants::getInstrCost()
which later in D150464 was altered into CodeMetrics::NumInsts since
the metric is supposed to model TargetTransformInfo::TCK_CodeSize.
However, we omitted adjusting MinFunctionSize in that commit.
Differential Revision: https://reviews.llvm.org/D157123
More information about the All-commits
mailing list