https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112272
Bug ID: 112272 Summary: suboptimal zero-initialization of struct of mixed pointer and integer types Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: lh_mouse at 126 dot com Target Milestone: --- Testcase: (https://gcc.godbolt.org/z/97cThnszM) ``` struct data_mixed { int* p1; int* p2; __INTPTR_TYPE__ i3; int* p4; constexpr data_mixed() noexcept : p1(), p2(), i3(), p4() { } }; data_mixed create_data_mixed() { return {}; // somehow suboptimal ↓↓ // mov QWORD PTR [rdi+16], 0 // mov QWORD PTR [rdi+24], 0 // vmovdqu XMMWORD PTR [rdi], xmm0 } struct data_ptrs { int* p1; int* p2; void* p3; int* p4; constexpr data_ptrs() noexcept : p1(), p2(), p3(), p4() { } }; data_ptrs create_data_ptrs() { return {}; // vmovdqu YMMWORD PTR [rdi], ymm0 } struct data_ints { __INTPTR_TYPE__ p1; __INTPTR_TYPE__ p2; __INTPTR_TYPE__ p3; __INTPTR_TYPE__ p4; constexpr data_ints() noexcept : p1(), p2(), p3(), p4() { } }; data_ints create_data_ints() { return {}; // vmovdqu YMMWORD PTR [rdi], ymm0 } ``` I believe these structs should be initialized in the same way, by storing a zero YMM register. However mixed use of pointer and integer types seems to prevent that. This is not specific to GCC 13; in GCC 12 it used to prevent vectorization completely.