https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125905
Drea Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2026-09-20
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
CC| |pinskia at gcc dot gnu.org
--- Comment #1 from Drea Pinski <pinskia at gcc dot gnu.org> ---
```
unsigned long
cond_mask_0 (bool flag, unsigned long mask, unsigned long target)
{
return flag ? target | mask : target & ~mask;
}
unsigned long
cond_mask_1 (bool flag, unsigned long x, unsigned long y)
{
unsigned long t = (~x & y);
unsigned long t1 = flag ? x : 0;
return t | t1;
}
```
At -O1, cond_mask_1 gets what you want, while at -O2 (due to pre), we get back
to cond_mask_0 .