https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117634
Bug ID: 117634 Summary: memset/struct copy transformation into memset/memset is not done if not address Product: gcc Version: 15.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: enhancement Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Target Milestone: --- Take: ``` struct S { char a[1024]; }; void f(void*); void f3 (struct S *b) { struct S a; __builtin_memset (b, 0, sizeof (*b)); a = *b; f(&a); f(b); } void f4 (struct S *b) { struct S a; __builtin_memset (b, 0, sizeof (*b)); a = (struct S){}; f(&a); } void f5 () { struct S a, b; __builtin_memset (&b, 0, sizeof (b)); a = b; f(&a); f(&b); } ``` These all should be optimized to 2 memset. currently f5 (and f4 which is already 2 memset) can be optimized to a memset via the code in optimize_memcpy_to_memset but f3 is not handled.