public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "memmerto at ca dot ibm.com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/95661] New: Code built with -m32 uses SSE2 instructions
Date: Sat, 13 Jun 2020 01:24:48 +0000	[thread overview]
Message-ID: <bug-95661-4@http.gcc.gnu.org/bugzilla/> (raw)

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).

             reply	other threads:[~2020-06-13  1:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-13  1:24 memmerto at ca dot ibm.com [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-95661-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).