https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114169
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|normal |enhancement Status|UNCONFIRMED |NEW Last reconfirmed| |2024-03-07 Ever confirmed|0 |1 Component|rtl-optimization |middle-end --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Confirmed. Reduced testcase: ``` struct S0 { int f0; int t[3+4]; }; struct S0 g_2; struct S0 g_4; void func_1() { //struct S0 b = g_2; g_4 = g_2; struct S0 b = g_4; g_4.f0 = 0; g_2 = b; } void func_2() { struct S0 b = g_2; g_4 = b; g_4.f0 = 0; g_2 = b; } ``` We still get an extra load/store with func_2 but it least it is not a dependent load/store ... Basically GCC doesn't notice that g_2 = b = g_2 was a no-op.