https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101610

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #2)
> 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); }))

But I don't think this should be done at the gimple level unless we have a
place were we decide it should be considered "lowered gimple".
I will be doing a simplify-rtx.c patch for this case which should get some code
generation improvement but not with the original case as we need to export the
non-zero bits down from gimple to RTL still (though I hear someone is working
on keeping around the non-zero bits around through out the whole RTL phase).

Reply via email to