https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101610
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://gcc.gnu.org/bugzill | |a/show_bug.cgi?id=96921 Status|UNCONFIRMED |ASSIGNED Last reconfirmed| |2021-07-28 Ever confirmed|0 |1 Assignee|unassigned at gcc dot gnu.org |pinskia at gcc dot gnu.org --- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- So looking at this one (and one which I just assigned myself): unsigned long f(unsigned long x) { if (x >= 64)__builtin_unreachable(); x = x ^ 63; unsigned long y = x; ;; Range is still [0,63] unsigned long z = 64 - y; ;; is similar to (63 - y) +1 -> (y ^ 63) + 1 -> x + 1 return z; } So mine: Something like: (simplify (minus INTEGER_CST@0 SSA_NAME@1) (if (exact_power2(@0) && get_nonzero_bits(@1) == (@0 - 1) (add (bit_xor! @1 @0) {build_one_cst (type); }))