https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109393
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|tree-optimization |c
Status|UNCONFIRMED |NEW
Last reconfirmed| |2023-04-11
Ever confirmed|0 |1
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
It's probably a mismatch of GENERIC/GIMPLE folding. In this case it's
pointer_int_sum prematurely distributing the multiplication:
/* Return a tree for the sum or difference (RESULTCODE says which)
of pointer PTROP and integer INTOP. */
tree
pointer_int_sum (location_t loc, enum tree_code resultcode,
tree ptrop, tree intop, bool complain)
{
...
/* If what we are about to multiply by the size of the elements
contains a constant term, apply distributive law
and multiply that constant term separately.
This helps produce common subexpressions. */
but this kind of stuff shouldn't be done by the frontends these days.
Gating this fixes the issue. I think this piece of code should be axed
(after careful evaluation of its effect)