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

--- Comment #4 from Drea Pinski <pinskia at gcc dot gnu.org> ---
Comment on attachment 64700
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=64700
Proposed patch

>diff --git a/gcc/match.pd b/gcc/match.pd
>index e0d7ef80e14..d3b68fa8d93 100644
>--- a/gcc/match.pd
>+++ b/gcc/match.pd
>@@ -1831,6 +1831,13 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
>       && wi::to_wide (@1) != wi::min_value (TYPE_PRECISION (type),
>                                             SIGNED))
>     (minus (plus @1 { build_minus_one_cst (type); }) @0))))
>+
>+/* (~a)>>a -> -1 for signed a.  */
>+(simplify
>+ (rshift (bit_not @0) @0)

Add an optional convert on the rhs of the rshift.  

>+ (if (INTEGRAL_TYPE_P (type)
>+      && !TYPE_UNSIGNED (type))
>+  { build_int_cst (type, -1); }))
> #endif
> 
> /* ~(X >> Y) -> ~X >> Y if ~X can be simplified.  */

Reply via email to