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

--- Comment #1 from Yichao Yu <yyc1992 at gmail dot com> ---
The problem is still there when compiled with -O2

```
f:
        pushq   %rbp
        vmovq   (%r8), %xmm1
        movq    %rcx, %rax
        vmovq   8(%r8), %xmm0
        vaddsd  (%rdx), %xmm1, %xmm1
        vaddsd  8(%rdx), %xmm0, %xmm0
        movq    %rsp, %rbp
        andq    $-16, %rsp
        vmovsd  %xmm1, (%rcx)
        vmovsd  %xmm0, 8(%rcx)
        leave
        ret
```


but is not there under `-O2` when the arguments and results are passed
explicitly by reference.

```
void f2(vdouble *res, const vdouble *x, const vdouble *y)
{
    *res = (vdouble){x->x1 + y->x1, x->x2 + y->x2};
}
```


```
f2:
        vmovsd  8(%rdx), %xmm0
        vmovsd  (%rdx), %xmm1
        vaddsd  8(%r8), %xmm0, %xmm0
        vaddsd  (%r8), %xmm1, %xmm1
        vmovsd  %xmm0, 8(%rcx)
        vmovsd  %xmm1, (%rcx)
```

The problem comes back, however, with the explicit pass by reference version
when compiled under -O3

```
f2:
        pushq   %rbp
        vmovapd (%rdx), %xmm0
        vaddpd  (%r8), %xmm0, %xmm0
        movq    %rsp, %rbp
        andq    $-16, %rsp
        vmovaps %xmm0, (%rcx)
        leave
        ret
```

Reply via email to