[Bug rtl-optimization/124793] RISC-V RTL optimization for "(X EQ 0) ? 0 : FN (X) => FN (X)"
pinskia at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Apr 6 17:32:23 GMT 2026
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124793
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
Last reconfirmed| |2026-04-06
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.
>We have match.pd code that covers this case for gimple
There is also extra phiopt code to handle popcount see
cond_removal_in_builtin_zero_pattern (because of a cast is not handled by
phiopt match yet).
The problem in the second popcount (the first one is handled) is we have:
```
if (b_7(D) != 0)
goto <bb 3>; [89.00%]
else
goto <bb 4>; [11.00%]
<bb 3> [local count: 105119324]:
_27 = (unsigned long) b_7(D);
_2 = .POPCOUNT (_27);
<bb 4> [local count: 118111600]:
# prephitmp_21 = PHI <_10(2), _2(3)>
```
Oh I see the issue now.
This is b ? popcount(b) : c
Maybe the code in cond_removal_in_builtin_zero_pattern could be convert this
into:
t = popcount(b)
t != 0 ? t : c
When PROP_last_full_fold is set?
More information about the Gcc-bugs
mailing list