public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "foom at fuhm dot net" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/98522] New: _mm_cvttps_pi32 and _mm_cvtps_pi32 raise spurious FP exceptions
Date: Tue, 05 Jan 2021 02:54:42 +0000	[thread overview]
Message-ID: <bug-98522-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 98522
           Summary: _mm_cvttps_pi32 and _mm_cvtps_pi32 raise spurious FP
                    exceptions
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: foom at fuhm dot net
  Target Milestone: ---

This is a regression due to the MMX in SSE work in GCC10. As far as I can tell,
it affects only these two functions.

Example test, which should return 0, but instead throws SIGFPE:

#pragma stdc fenv_access

#define _GNU_SOURCE
#include <emmintrin.h>
#include <fenv.h>

__attribute__((noinline)) __m64 test(__m128 a) {
  return _mm_cvtt_ps2pi(a);
}

int main() {
  feenableexcept(FE_INVALID);
  __m128 x = (__m128)(__m128i){0x0000000000000000LL, 0x7fffffffffffffffLL};
  volatile __m64 y = test(x);
}


In GCC 10 and trunk, the function test is compiled to:
        cvttps2dq       xmm0, xmm0
        ret
which will convert the upper 64 bits as well as the lower 64 bits -- and
therefore raises FP exceptions accordingly. But, it ought to be ignoring the
upper 64bits.

             reply	other threads:[~2021-01-05  2:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-05  2:54 foom at fuhm dot net [this message]
2021-01-05 10:07 ` [Bug target/98522] " ubizjak at gmail dot com
2021-01-06  9:47 ` ubizjak at gmail dot com

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