https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122597
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Blocks| |121364
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
Last reconfirmed| |2025-11-08
Component|c++ |tree-optimization
Keywords| |missed-optimization
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This is just a copy prop for aggregates issue.
Though it is hard to implement:
```
big = *.LC0;
goto <bb 7>; [INV]
<bb 6> :
i_28 = *__for_begin_3;
s.2_4 = s;
_5 = s.2_4 + i_28;
s = _5;
__for_begin_30 = __for_begin_3 + 4;
<bb 7> :
# __for_begin_3 = PHI <&MEM <const int[100000]> [(void *)&big](5),
__for_begin_30(6)>
if (__for_begin_3 != &MEM <const struct array> [(void *)&big + 400000B])
goto <bb 6>; [INV]
else
goto <bb 8>; [INV]
```
clang hits a limit with 100000.
With 1000 it looks like LLVM can do the copy prop.
Their SRA (SROA) pass is able the optimize the above.
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121364
[Bug 121364] [meta-bug] copy prop for aggregates