https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123017
Bug ID: 123017
Summary: [15/16 Regression] Very aggressive ifcvt results in
performance loss since
g:b219cbeda72d23b7ad6ff12cd159784b7ef00667
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: rtl-optimization
Assignee: tnfchris at gcc dot gnu.org
Reporter: tnfchris at gcc dot gnu.org
Target Milestone: ---
Target: aarch64*
Since g:b219cbeda72d23b7ad6ff12cd159784b7ef00667
The following
void f(const int *restrict in,
int *restrict out,
int n, int threshold)
{
for (int i = 0; i < n; ++i) {
int v = in[i];
if (v > threshold) {
int t = v * 3;
t += 7;
t ^= 0x55;
t *= 0x55;
t -= 0x5;
t &= 0xFE;
t ^= 0x55;
out[i] = t;
} else {
out[i] = v;
}
}
}
compiled at -O2
results in aggressive if-conversion which increases the number of dynamic
instructions and the latency of the loop as it has to wait for t to be
calculated now in all cases.
This has led to big performance losses in packages like zstd [1] which in turns
affects packaging and LTO speed.
[1] https://github.com/facebook/zstd/pull/4418#issuecomment-3004606000