https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123330
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Last reconfirmed| |2025-12-29
Severity|normal |enhancement
Status|UNCONFIRMED |NEW
Summary|Optimization fails with |Optimization fails with
|standard branchless idiom |standard branchless idiom
| |with power of 2s
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
>if not building with `-mlzcnt
No it is still undefined.
If you want to avoid the undefinedness of __builtin_clz you could just use:
`__builtin_clzg((unsigned)x, 64)`.
The problem here is `(x == 0) * 64` is transformed into `(x == 0) <<6` and then
that is not combined with `(x!=0)*b`