https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100004
Bug ID: 100004 Summary: Dead write not removed when indirection is introduced. Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: hiraditya at msn dot com Target Milestone: --- struct Foo { int x; }; struct Bar { int x; }; void alias(Foo* foo, Bar* bar) { foo->x = 5; foo->x = bar->x; } struct Wrap1 { Foo foo; }; struct Wrap2 { Foo foo; }; void assign_direct(Wrap1* w1, Wrap2* w2) { w1->foo.x = 5; w1->foo.x = w2->foo.x; } void assign_via_pointer(Wrap1* w1, Wrap2* w2) { Foo* f1 = &w1->foo; Foo* f2 = &w2->foo; f1->x = 5; f1->x = f2->x; } $ gcc-arm64 -O2 -std=c++17 -fstrict-aliasing -S -o - alias(Foo*, Bar*): ldr w1, [x1] str w1, [x0] ret assign_direct(Wrap1*, Wrap2*): ldr w1, [x1] str w1, [x0] ret assign_via_pointer(Wrap1*, Wrap2*): mov w2, 5 str w2, [x0] ldr w1, [x1] str w1, [x0] ret