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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Target|                            |x86_64-*-*, i?86-*-*
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2019-02-04
     Ever confirmed|0                           |1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.  Canonicalization might help to CSE this on the GIMPLE level.  The
following doesn't trigger though since we don't fold all stmts during VRP.

diff --git a/gcc/match.pd b/gcc/match.pd
index bccf4df05a2..bdd26a1c53b 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -717,6 +717,13 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
     { tree utype = unsigned_type_for (type); }
     (convert (rshift (lshift (convert:utype @0) @2) @3))))))

+(simplify
+ (convert (rshift (convert@2 @0) @1))
+ (if (!TYPE_UNSIGNED (TREE_TYPE (@0))
+      && tree_nop_conversion_p (TREE_TYPE (@2), TREE_TYPE (@0))
+      && tree_expr_nonnegative_p (@0))
+  (convert (rshift @0 @1))))
+
 /* Fold (C1/X)*C2 into (C1*C2)/X.  */
 (simplify
  (mult (rdiv@3 REAL_CST@0 @1) REAL_CST@2)

Reply via email to