https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82041
Bug ID: 82041 Summary: Windows i686 should not return float aggregates in ST0 Product: gcc Version: 7.2.0 Status: UNCONFIRMED Keywords: ABI, wrong-code Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: jistone at redhat dot com Target Milestone: --- Target: i686-w64-mingw32 This is nearly a clone of bug 82028, but it's less clear to me if it's actually a real problem. It may just be that gnu cdecl returns values differently than msvc cdecl, especially since I see that clang alters behavior for the two targets. 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 returns in ST0: 00000000 <_foo>: 0: 55 push %ebp 1: 89 e5 mov %esp,%ebp 3: 83 ec 08 sub $0x8,%esp 6: 8b 45 08 mov 0x8(%ebp),%eax 9: 89 45 f8 mov %eax,-0x8(%ebp) c: 8b 45 0c mov 0xc(%ebp),%eax f: 89 45 fc mov %eax,-0x4(%ebp) 12: dd 45 f8 fldl -0x8(%ebp) 15: d9 e1 fabs 17: dd 5d f8 fstpl -0x8(%ebp) 1a: dd 45 f8 fldl -0x8(%ebp) 1d: c9 leave 1e: c3 ret MSVC returns in EDX:EAX: 00000000 <_foo>: 0: 55 push %ebp 1: 8b ec mov %esp,%ebp 3: 83 ec 08 sub $0x8,%esp 6: f2 0f 10 45 08 movsd 0x8(%ebp),%xmm0 b: f2 0f 11 04 24 movsd %xmm0,(%esp) 10: e8 00 00 00 00 call 15 <_foo+0x15> 15: 83 c4 08 add $0x8,%esp 18: dd 5d 08 fstpl 0x8(%ebp) 1b: 8b 45 08 mov 0x8(%ebp),%eax 1e: 8b 55 0c mov 0xc(%ebp),%edx 21: 5d pop %ebp 22: c3 ret Clang for i686-w64-windows-gnu returns in ST0 like GCC: 00000000 <_foo>: 0: 55 push %ebp 1: 89 e5 mov %esp,%ebp 3: 83 e4 f8 and $0xfffffff8,%esp 6: 83 ec 18 sub $0x18,%esp 9: f2 0f 10 45 08 movsd 0x8(%ebp),%xmm0 e: f2 0f 11 44 24 08 movsd %xmm0,0x8(%esp) 14: f2 0f 10 44 24 08 movsd 0x8(%esp),%xmm0 1a: 0f 28 0d 00 00 00 00 movaps 0x0,%xmm1 21: 66 0f db c1 pand %xmm1,%xmm0 25: 66 0f 13 44 24 08 movlpd %xmm0,0x8(%esp) 2b: f2 0f 10 44 24 08 movsd 0x8(%esp),%xmm0 31: f2 0f 11 44 24 10 movsd %xmm0,0x10(%esp) 37: f2 0f 10 44 24 10 movsd 0x10(%esp),%xmm0 3d: f2 0f 11 04 24 movsd %xmm0,(%esp) 42: dd 04 24 fldl (%esp) 45: 89 ec mov %ebp,%esp 47: 5d pop %ebp 48: c3 ret Clang for i686-w64-windows-msvc returns in EDX:EAX like MSVC: 00000000 <_foo>: 0: 55 push %ebp 1: 89 e5 mov %esp,%ebp 3: 83 e4 f8 and $0xfffffff8,%esp 6: 83 ec 10 sub $0x10,%esp 9: f2 0f 10 45 08 movsd 0x8(%ebp),%xmm0 e: f2 0f 11 04 24 movsd %xmm0,(%esp) 13: f2 0f 10 04 24 movsd (%esp),%xmm0 18: 0f 28 0d 00 00 00 00 movaps 0x0,%xmm1 1f: 66 0f db c1 pand %xmm1,%xmm0 23: 66 0f 13 04 24 movlpd %xmm0,(%esp) 28: f2 0f 10 04 24 movsd (%esp),%xmm0 2d: f2 0f 11 44 24 08 movsd %xmm0,0x8(%esp) 33: 8b 44 24 08 mov 0x8(%esp),%eax 37: 8b 54 24 0c mov 0xc(%esp),%edx 3b: 89 ec mov %ebp,%esp 3d: 5d pop %ebp 3e: c3 ret $ gcc -v Using built-in specs. COLLECT_GCC=C:\msys64\mingw32\bin\gcc.exe COLLECT_LTO_WRAPPER=C:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/7.2.0/lto-wrapper.exe Target: i686-w64-mingw32 Configured with: ../gcc-7.2.0/configure --prefix=/mingw32 --with-local-prefix=/mingw32/local --build=i686-w64-mingw32 --host=i686-w64-mingw32 --target=i686-w64-mingw32 --with-native-system-header-dir=/mingw32/i686-w64-mingw32/include --libexecdir=/mingw32/lib --enable-bootstrap --with-arch=i686 --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=/mingw32 --with-mpfr=/mingw32 --with-mpc=/mingw32 --with-isl=/mingw32 --with-pkgversion='Rev1, Built by MSYS2 project' --with-bugurl=https://sourceforge.net/projects/msys2 --with-gnu-as --with-gnu-ld --disable-sjlj-exceptions --with-dwarf2 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: i686-w64-windows-gnu Thread model: posix InstalledDir: C:\msys64\mingw32\bin >cl Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24210 for x86 Copyright (C) Microsoft Corporation. All rights reserved.