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

            Bug ID: 89597
           Summary: Inconsistent vector calling convention on windows with
                    Clang and MSVC
           Product: gcc
           Version: 8.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: yyc1992 at gmail dot com
  Target Milestone: ---

For 256bit and 512bit vector return values, Clang and MSVC always returns them
in the corresponding registers even without `__vectorcall`. GCC, however,
returns the value as reference. Together with the missing support of
`__vectorcall`[1], this means that the code GCC generate for functions that
returns vector value is not compatible with any other compilers. The problem
does not exist for 128bit vectors.

Test case.

```
typedef double vdouble __attribute__((vector_size(32)));
vdouble f(vdouble x, vdouble y)
{
    return x + y;
}
```

GCC compiles this to,

```
f:
        vmovapd (%r8), %ymm0
        vaddpd  (%rdx), %ymm0, %ymm0
        movq    %rcx, %rax
        vmovapd %ymm0, (%rcx)
        vzeroupper
        ret
```

Clang compiles this to,

```
f:
        vmovapd (%rcx), %ymm0
        vaddpd  (%rdx), %ymm0, %ymm0
        retq
```

Given the stack alignment issue[2], I wonder if this can be fixed now without
breaking anyone's code. (i.e. everyone that's using it is probably broken
anyway due to the other bug...)

Disclaimer. I did all my test with clang. I believe MSVC behaves the same from
the compiled result I got from someone else and I don't have MSVC to personally
test it.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89485
[2] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54412

Reply via email to