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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |easyhack,
                   |                            |missed-optimization
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2019-09-06
     Ever confirmed|0                           |1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.

/* (A / (1 << B)) -> (A >> B).
   Only for unsigned A.  For signed A, this would not preserve rounding
   toward zero.
   For example: (-1 / ( 1 << B)) !=  -1 >> B.  */
(simplify
 (trunc_div @0 (lshift integer_onep@1 @2))
 (if ((TYPE_UNSIGNED (type) || tree_expr_nonnegative_p (@0))
      && (!VECTOR_TYPE_P (type)
          || target_supports_op_p (type, RSHIFT_EXPR, optab_vector)
          || target_supports_op_p (type, RSHIFT_EXPR, optab_scalar)))
  (rshift @0 @2)))

lacks a (convert? ...) on the divisor where at least sign-changes are OK.

Reply via email to