[Bug rtl-optimization/66552] Missed optimization when shift amount is result of signed modulus

jakub at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Feb 14 08:31:00 GMT 2020


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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #14 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #8)
> Some typos:
> (simplify
>  (rshift @0 (mod @1 integer_pow2p@2))
>  (rshift @0 (bit_and @1 (minus @2 { build_int_cst (TREE_TYPE (@2), 1); }))))
> 
> This would be under the for:
> (for mod (ceil_mod floor_mod round_mod trunc_mod)

It should be also
(for shift (lshift rshift)
and use shift instead of rshift, because it applies to left shifts equally.
Maube for rotates too, dunno if we consider the negative or out of bounds
amounts UB or not for those, I bet they could be matched from expressions where
it would be UB or where it wouldn't.  Certainly if the @2 is the precision of
the rotated value, it would be ok anyway (even if we don't consider int32 r>>
-1 UB, it will still be the same thing as int32 r>> 31 (-1 & 31).


More information about the Gcc-bugs mailing list