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

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
At least from the comments it seems fold_plusminus_mult_expr only handles
     (A * C) +- (B * C) -> (A +- B) * C
     (A * C) +- A -> A * (C +- 1)
so for the testcases in question that is the latter and we punt because it is
not wrapping arithmetics and it doesn't match one of the special cases in
there.
The suggestion I'll try to work on is to check if C isn't a plus/minus expr
with constant second operand that doesn't go in the other direction and thus
where the transformation isn't introducing UB.
I guess it should be enough to do this in match.pd though.

Reply via email to