https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106245
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Ever confirmed|0 |1 Last reconfirmed| |2022-07-10 Target| |x86_64-linux-gnu --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Confirmed. Note on aarch64, it is optimized down to &1 on the RTL level. The issue is we don't optimize: int f(int a) { return (a << 31) >> 31; } Into: int f(int a) { return -(a&1); } I thought I had saw a bug report about that but I can't find it.