https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124902
Drea Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Summary|[LoopVectorize][AArch64] |sum reduction of 2
|GCC fails to vectorize |masked_loads not vectorized
|conditional reduction with |
|`if` statement that Clang |
|vectorizes with SVE |
Status|UNCONFIRMED |NEW
Last reconfirmed| |2026-04-16
Component|target |tree-optimization
--- Comment #1 from Drea Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.
Simplified testcase:
```
unsigned int foo(
const unsigned * __restrict__ a,
const unsigned * __restrict__ b,
const unsigned * __restrict__ c,
int n
) {
unsigned sum = 0;
for (int i = 0; i<n; i++)
{
if (a[i] != 0) {
sum += a[i];
sum += b[i];
}
}
return sum;
}
```
GCC does not detect this as a sum reduction.
This is because ifcvt does not produce COND_ADD here even though it should.
We get from ifcvt:
_27 = _4 != 0;
sum_13 = _4 + sum_19;
...
sum_15 = _6 + sum_13;
sum_7 = _27 ? sum_15 : sum_19;
But that is two COND_ADD and ifcvt only tries to detect one COND_ADD here.