[Bug c/82028] New: Windows x86_64 should not pass float aggregates in xmm
jistone at redhat dot com
gcc-bugzilla@gcc.gnu.org
Tue Aug 29 22:35:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82028
Bug ID: 82028
Summary: Windows x86_64 should not pass float aggregates in xmm
Product: gcc
Version: 7.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: jistone at redhat dot com
Target Milestone: ---
Given this input foo.c:
#include <math.h>
typedef struct { double x; } Foo;
Foo foo(Foo f) {
f.x = fabs(f.x);
return f;
}
mingw-gcc produces code that uses XMM0 for both the argument and return.
0000000000000000 <foo>:
0: 55 push %rbp
1: 48 89 e5 mov %rsp,%rbp
4: f2 0f 11 45 10 movsd %xmm0,0x10(%rbp)
9: f2 0f 10 4d 10 movsd 0x10(%rbp),%xmm1
e: f3 0f 7e 05 00 00 00 movq 0x0(%rip),%xmm0 # 16 <foo+0x16>
15: 00
16: 66 0f 54 c1 andpd %xmm1,%xmm0
1a: f2 0f 11 45 10 movsd %xmm0,0x10(%rbp)
1f: f2 0f 10 45 10 movsd 0x10(%rbp),%xmm0
24: 5d pop %rbp
25: c3 retq
MSVC passes the argument in RCX and the return value in RAX:
0000000000000000 <foo>:
0: 48 89 4c 24 08 mov %rcx,0x8(%rsp)
5: 48 83 ec 28 sub $0x28,%rsp
9: f2 0f 10 44 24 30 movsd 0x30(%rsp),%xmm0
f: e8 00 00 00 00 callq 14 <foo+0x14>
14: f2 0f 11 44 24 30 movsd %xmm0,0x30(%rsp)
1a: 48 8b 44 24 30 mov 0x30(%rsp),%rax
1f: 48 83 c4 28 add $0x28,%rsp
23: c3 retq
And mingw-clang uses RCX/RAX like MSVC:
0000000000000000 <foo>:
0: 48 83 ec 10 sub $0x10,%rsp
4: 48 89 0c 24 mov %rcx,(%rsp)
8: f2 0f 10 04 24 movsd (%rsp),%xmm0
d: 0f 28 0d 00 00 00 00 movaps 0x0(%rip),%xmm1 # 14 <foo+0x14>
14: 66 0f db c1 pand %xmm1,%xmm0
18: f2 0f 11 04 24 movsd %xmm0,(%rsp)
1d: 48 8b 0c 24 mov (%rsp),%rcx
21: 48 89 4c 24 08 mov %rcx,0x8(%rsp)
26: 48 8b 44 24 08 mov 0x8(%rsp),%rax
2b: 48 83 c4 10 add $0x10,%rsp
2f: c3 retq
$ gcc -v
Using built-in specs.
COLLECT_GCC=C:\msys64\mingw64\bin\gcc.exe
COLLECT_LTO_WRAPPER=C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../gcc-7.2.0/configure --prefix=/mingw64
--with-local-prefix=/mingw64/local --build=x86_64-w64-mingw32
--host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32
--with-native-system-header-dir=/mingw64/x86_64-w64-mingw32/include
--libexecdir=/mingw64/lib --enable-bootstrap --with-arch=x86-64
--with-tune=generic --enable-languages=c,lto,c++,objc,obj-c++,fortran,ada
--enable-shared --enable-static --enable-libatomic --enable-threads=posix
--enable-graphite --enable-fully-dynamic-string --enable-libstdcxx-time=yes
--disable-libstdcxx-pch --disable-libstdcxx-debug --disable-isl-version-check
--enable-lto --enable-libgomp --disable-multilib --enable-checking=release
--disable-rpath --disable-win32-registry --disable-nls --disable-werror
--disable-symvers --with-libiconv --with-system-zlib --with-gmp=/mingw64
--with-mpfr=/mingw64 --with-mpc=/mingw64 --with-isl=/mingw64
--with-pkgversion='Rev1, Built by MSYS2 project'
--with-bugurl=https://sourceforge.net/projects/msys2 --with-gnu-as
--with-gnu-ld
Thread model: posix
gcc version 7.2.0 (Rev1, Built by MSYS2 project)
$ clang -v
clang version 4.0.0 (tags/RELEASE_400/final)
Target: x86_64-w64-windows-gnu
Thread model: posix
InstalledDir: C:\msys64\mingw64\bin
>cl
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24210 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
More information about the Gcc-bugs
mailing list