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

--- Comment #9 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Matching expression match.pd:2310, gimple-match-3.cc:90
Matching expression match.pd:2310, gimple-match-3.cc:90
Applying pattern match.pd:4890, gimple-match-2.cc:4798
Matching expression match.pd:160, gimple-match-10.cc:33
Matching expression match.pd:2243, gimple-match-5.cc:20
Matching expression match.pd:160, gimple-match-10.cc:33
Applying pattern match.pd:5024, gimple-match-7.cc:13241
Applying pattern match.pd:2404, gimple-match-2.cc:4387
gimple_simplified to _32 = (<unnamed-signed:1>) _2;
_29 = -_32;

The problem match pattern (r13-1162-g9991d84d2a8435) is:
```
/* Narrow integer multiplication by a zero_one_valued_p operand.
   Multiplication by [0,1] is guaranteed not to overflow.  */
(simplify
 (convert (mult@0 zero_one_valued_p@1 INTEGER_CST@2))
 (if (INTEGRAL_TYPE_P (type)
      && INTEGRAL_TYPE_P (TREE_TYPE (@0))
      && TYPE_PRECISION (type) < TYPE_PRECISION (TREE_TYPE (@0)))
  (mult (convert @1) (convert @2))))
```

  _36 = _27 * 5;
  _29 = (<unnamed-signed:1>) _36;

We go from `(<unnamed-signed:1>)(_27 *5)` to `((<unnamed-signed:1>)_27) * -1`
which does overflow.

The only case where is an overflow is `signed:1` so we should reject that I
think.

Reply via email to