public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/95661] New: Code built with -m32 uses SSE2 instructions
@ 2020-06-13  1:24 memmerto at ca dot ibm.com
  2020-06-13  9:26 ` [Bug target/95661] " mikpelinux at gmail dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: memmerto at ca dot ibm.com @ 2020-06-13  1:24 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 95661
           Summary: Code built with -m32 uses SSE2 instructions
           Product: gcc
           Version: 8.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: memmerto at ca dot ibm.com
  Target Milestone: ---

When building 32-bit code with -m32, SSE2 instructions are generated.  This is
in contrast to the docs.

https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html
"The -m32 option sets int, long, and pointer types to 32 bits, and generates
code that runs on any i386 system."

In particular, the code to do floating-point/integer conversions appear to use
SSE2 instructions.

Compiler:

$ /opt/rh/devtoolset-8/root/usr/bin/gcc -v
Using built-in specs.
COLLECT_GCC=/opt/rh/devtoolset-8/root/usr/bin/gcc
COLLECT_LTO_WRAPPER=/opt/rh/devtoolset-8/root/usr/libexec/gcc/x86_64-redhat-linux/8/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap
--enable-languages=c,c++,fortran,lto --prefix=/opt/rh/devtoolset-8/root/usr
--mandir=/opt/rh/devtoolset-8/root/usr/share/man
--infodir=/opt/rh/devtoolset-8/root/usr/share/info
--with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared
--enable-threads=posix --enable-checking=release --enable-multilib
--with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions
--enable-gnu-unique-object --enable-linker-build-id
--with-gcc-major-version-only --with-linker-hash-style=gnu
--with-default-libstdcxx-abi=gcc4-compatible --enable-plugin
--enable-initfini-array
--with-isl=/builddir/build/BUILD/gcc-8.3.1-20190311/obj-x86_64-redhat-linux/isl-install
--disable-libmpx --enable-gnu-indirect-function --with-tune=generic
--with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 8.3.1 20190311 (Red Hat 8.3.1-3) (GCC)

Compile Command:

gcc -c -m32 t.c -save-temps -fverbose-asm -o t.o

Testcase:

#include <stdio.h>
#include <float.h>

int main(void)
{
  double d = 100.0;
  int i = (int)d;
  printf("%d\n",i);
}

Assembly Fragment:

# t.c:7:   int i = (int)d;
        movsd   -16(%ebp), %xmm0        # d, tmp90
        cvttsd2si       %xmm0, %eax     # tmp90, tmp91
        movl    %eax, -20(%ebp) # tmp91, i

I would expect 387 instructions to be generated (since -mfpmath is the default
for 32-bit targets).

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/95661] Code built with -m32 uses SSE2 instructions
  2020-06-13  1:24 [Bug c/95661] New: Code built with -m32 uses SSE2 instructions memmerto at ca dot ibm.com
@ 2020-06-13  9:26 ` mikpelinux at gmail dot com
  2020-06-13  9:59 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: mikpelinux at gmail dot com @ 2020-06-13  9:26 UTC (permalink / raw)
  To: gcc-bugs

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

Mikael Pettersson <mikpelinux at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mikpelinux at gmail dot com

--- Comment #1 from Mikael Pettersson <mikpelinux at gmail dot com> ---
(In reply to Matt Emmerton from comment #0)
> --with-bugurl=http://bugzilla.redhat.com/bugzilla

That's a Red Hat compiler, with Red Hat modifications and configuration, and as
--with-bugurl indicates, they're the ones you should report the bug to.

> --with-arch_32=x86-64

This is what's causing SSE2 in 32-bit code.

I think this needs to be --with-arch-32=i386, or the multilibs need to
explicitly include i386, and then you could compile with -m32 -mcpu=i386.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/95661] Code built with -m32 uses SSE2 instructions
  2020-06-13  1:24 [Bug c/95661] New: Code built with -m32 uses SSE2 instructions memmerto at ca dot ibm.com
  2020-06-13  9:26 ` [Bug target/95661] " mikpelinux at gmail dot com
@ 2020-06-13  9:59 ` pinskia at gcc dot gnu.org
  2020-06-13 10:52 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2020-06-13  9:59 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Not a bug as GCC is configured to default to include sse2 for 32bits.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/95661] Code built with -m32 uses SSE2 instructions
  2020-06-13  1:24 [Bug c/95661] New: Code built with -m32 uses SSE2 instructions memmerto at ca dot ibm.com
  2020-06-13  9:26 ` [Bug target/95661] " mikpelinux at gmail dot com
  2020-06-13  9:59 ` pinskia at gcc dot gnu.org
@ 2020-06-13 10:52 ` jakub at gcc dot gnu.org
  2020-06-13 12:59 ` memmerto at ca dot ibm.com
  2023-07-10  5:10 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-06-13 10:52 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
And it is an intentional disto decision, because 32-bit kernels aren't
supported (not even shipped) in RHEL and thus SSE2 is required.
You can always use -march=i386 or -mno-sse etc. to override the defaults.
E.g. in Fedora 32-bit CPUs are still supported and the configured compiler
defaults to -march=i686 for 32-bit compilation.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/95661] Code built with -m32 uses SSE2 instructions
  2020-06-13  1:24 [Bug c/95661] New: Code built with -m32 uses SSE2 instructions memmerto at ca dot ibm.com
                   ` (2 preceding siblings ...)
  2020-06-13 10:52 ` jakub at gcc dot gnu.org
@ 2020-06-13 12:59 ` memmerto at ca dot ibm.com
  2023-07-10  5:10 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: memmerto at ca dot ibm.com @ 2020-06-13 12:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Matt Emmerton <memmerto at ca dot ibm.com> ---
Thank you everyone.  This fully explains why we were still getting SSE in
32-bit mode.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/95661] Code built with -m32 uses SSE2 instructions
  2020-06-13  1:24 [Bug c/95661] New: Code built with -m32 uses SSE2 instructions memmerto at ca dot ibm.com
                   ` (3 preceding siblings ...)
  2020-06-13 12:59 ` memmerto at ca dot ibm.com
@ 2023-07-10  5:10 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-07-10  5:10 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|INVALID                     |DUPLICATE

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This is a dup of bug 109954 in the end which was fixed.

*** This bug has been marked as a duplicate of bug 109954 ***

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-07-10  5:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-13  1:24 [Bug c/95661] New: Code built with -m32 uses SSE2 instructions memmerto at ca dot ibm.com
2020-06-13  9:26 ` [Bug target/95661] " mikpelinux at gmail dot com
2020-06-13  9:59 ` pinskia at gcc dot gnu.org
2020-06-13 10:52 ` jakub at gcc dot gnu.org
2020-06-13 12:59 ` memmerto at ca dot ibm.com
2023-07-10  5:10 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).