https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93896

            Bug ID: 93896
           Summary: Store merging uses SSE only for trivial types
           Product: gcc
           Version: 9.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msharov at users dot sourceforge.net
  Target Milestone: ---

struct M {
    constexpr M() :p{},sz{},cz{}{}
public:
    char* p;
    unsigned sz;
    unsigned cap;
};

struct A { M a,b,c; A(); };
A::A() :a{},b{},c{}{}

gcc 9.2.1 with -march=native -Os on Haswell generates:

_ZN1AC2Ev:
        movq    $0, (%rdi)
        movq    $0, 8(%rdi)
        movq    $0, 16(%rdi)
        movq    $0, 24(%rdi)
        movq    $0, 32(%rdi)
        movq    $0, 40(%rdi)
        ret

Store merging is obviously working here, but does not use SSE movups. If the
constructor is removed or defaulted the output is:

_ZN1AC2Ev:
        vpxor   %xmm0, %xmm0, %xmm0
        vmovups %xmm0, (%rdi)
        vmovups %xmm0, 16(%rdi)
        vmovups %xmm0, 32(%rdi)
        ret

Whether the type is trivial should not matter by the time store merging occurs,
but for some reason it does.

Reply via email to