https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110035
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |missed-optimization Ever confirmed|0 |1 Severity|normal |enhancement Last reconfirmed| |2023-05-30 Status|UNCONFIRMED |NEW --- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- In the case of x86_64, it is just moving the loads across the operator new, I think: vect_SR.14_5 = MEM <vector(2) long unsigned int> [(struct MyClass &)obj_2(D)]; vect_SR.15_28 = MEM <vector(2) long unsigned int> [(struct MyClass &)obj_2(D) + 16]; vect_SR.16_30 = MEM <vector(2) long unsigned int> [(struct MyClass &)obj_2(D) + 32]; _6 = operator new (48); MEM <vector(2) long unsigned int> [(struct MyClass2 *)_6] = vect_SR.14_5; MEM <vector(2) long unsigned int> [(struct MyClass2 *)_6 + 16B] = vect_SR.15_28; MEM <vector(2) long unsigned int> [(struct MyClass2 *)_6 + 32B] = vect_SR.16_30; HandleMyClass2 (_6); [tail call] Other targets is moving across the operator new too: D.14580.__obj = *obj_2(D); _6 = operator new (48); MEM[(struct MyClass2 *)_6].f = D.14580; More obvious Reduced testcase: ``` struct MyClass { unsigned long long arr[128]; }; [[gnu::noipa]] void sink(void *m){} void gg(MyClass &a) { MyClass c = a; MyClass *b = new MyClass; *b = c; sink(b); } ``` There might be a dup of this issue too.