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

            Bug ID: 99668
           Summary: Converting argument _Complex double to double vector
                    causes STLF stall
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rguenth at gcc dot gnu.org
  Target Milestone: ---

Consider

_Complex double a, b;
typedef double v2df __attribute__((vector_size(16)));
v2df foo (_Complex double x)
{
  return *(v2df *)&x;
}

which on GIMPLE is represented as the simple

v2df foo (complex double x)
{
  v2df _2;
  _2 = VIEW_CONVERT_EXPR<v2df>(x_3(D));
  return _2;
}

but since on x86_64 _Complex double are passed in %xmm0 and %xmm1 we end up
with spilling x to the stack:

foo:
.LFB0:
        .cfi_startproc
        movsd   %xmm0, -24(%rsp)
        movsd   %xmm1, -16(%rsp)
        movupd  -24(%rsp), %xmm0
        ret

Ideally GIMPLE would know that a V_C_E isn't a good representation here
but improving RTL expansion should be possible as well.  We expand
x_3(D) to (concat:DC ...) but the V_C_E expansion path misses special-casing
of this.  The MEM_REF expansion code can deal with this so eventually
splitting out parts of that support is possible.

In the end we want a simple

        movlhps %xmm1, %xmm0

Reply via email to