[Bug target/123017] [15 Regression] Very aggressive ifcvt results in performance loss since g:b219cbeda72d23b7ad6ff12cd159784b7ef00667
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Mar 30 14:56:50 GMT 2026
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123017
--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-15 branch has been updated by Tamar Christina
<tnfchris@gcc.gnu.org>:
https://gcc.gnu.org/g:d6a1eaafb6ba95cdd91d95130aa6af9a35e23634
commit r15-11018-gd6a1eaafb6ba95cdd91d95130aa6af9a35e23634
Author: Tamar Christina <tamar.christina@arm.com>
Date: Mon Mar 30 15:55:01 2026 +0100
AArch64: Add if-conversion target cost model [PR123017][GCC 15 backport]
This patch implements an if-conversion cost model for AArch64. AArch64
has a
number of conditional instructions that need to be accounted for, however
this
initial version keeps things simple and is only really concerned about
csel.
The issue specifically with csel is that it may have to wait for two
argument
to be evaluated before it can be executed. This means it has a direct
correlation to increases in dynamic instructions.
To fix this I add a new tuning parameter that indicates a rough estimation
of
the branch misprediction cost of a branch. We then accept if-conversion
while
the cost of this multiplied by the cost of branches is cheaper.
There is a basic detection of CINC and CSET because these usually are ok.
We
also accept all if-conversion when not inside a loop. Because CE is not an
RTL
SSA pass we can't do more extensive checks like checking if the csel is a
loop
carried dependency. As such this is a best effort thing and intends to
catch the
most egregious cases like the above.
This recovers the ~25% performance loss in zstd decoding and gives better
results than GCC 14 which was before the regression happened.
Additionally I've benchmarked on a number of cores all the attached
examples
and checked various cases. On average the patch gives an improvement
between
20-40%.
[1] https://github.com/facebook/zstd/pull/4418#issuecomment-3004606000
gcc/ChangeLog:
PR target/123017
* config/aarch64/aarch64-protos.h (struct cpu_branch_cost): Add
br_mispredict_factor.
* config/aarch64/aarch64.cc (aarch64_max_noce_ifcvt_seq_cost,
aarch64_noce_conversion_profitable_p,
TARGET_MAX_NOCE_IFCVT_SEQ_COST,
TARGET_NOCE_CONVERSION_PROFITABLE_P): New.
* config/aarch64/tuning_models/generic.h (generic_branch_cost): Add
br_mispredict_factor.
* config/aarch64/tuning_models/generic_armv8_a.h: Remove
generic_armv8_a_branch_cost and use generic_branch_cost.
gcc/testsuite/ChangeLog:
PR target/123017
* gcc.target/aarch64/pr123017_1.c: New test.
* gcc.target/aarch64/pr123017_2.c: New test.
* gcc.target/aarch64/pr123017_3.c: New test.
* gcc.target/aarch64/pr123017_4.c: New test.
* gcc.target/aarch64/pr123017_5.c: New test.
* gcc.target/aarch64/pr123017_6.c: New test.
* gcc.target/aarch64/pr123017_7.c: New test.
More information about the Gcc-bugs
mailing list