public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "liuhongt at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug target/115161] [15 Regression] highway-1.0.7 miscompilation of some SSE2 intrinsics Date: Wed, 22 May 2024 01:06:09 +0000 [thread overview] Message-ID: <bug-115161-4-l0t0V2HFrS@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-115161-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115161 --- Comment #11 from Hongtao Liu <liuhongt at gcc dot gnu.org> --- (In reply to Jakub Jelinek from comment #10) > Any of the floating point to integer intrinsics if they have out of range > value (haven't checked whether floating point to unsigned intrinsic is a > problem too or not). > No matter if it is float or double (dunno if _Float16 too, or __bf16), and > no matter if it is scalar intrinsic (ss/sd etc.) or vector and how many > vector elements. > But, this isn't really a regression, GCC has always behaved that way, the > only thing that actually changed is that perhaps we can constant fold more > than we used to do in the past. > When not using intrinsics, IMNSHO we should keep doing what we did before. Can we restrict them under flag_trapping_math? .i.e diff --git a/gcc/simplify-rtx.cc b/gcc/simplify-rtx.cc index 53f54d1d392..b7a770dad60 100644 --- a/gcc/simplify-rtx.cc +++ b/gcc/simplify-rtx.cc @@ -2256,14 +2256,25 @@ simplify_const_unary_operation (enum rtx_code code, machine_mode mode, switch (code) { case FIX: + /* According to IEEE standard, for conversions from floating point to + integer. When a NaN or infinite operand cannot be represented in + the destination format and this cannot otherwise be indicated, the + invalid operation exception shall be signaled. When a numeric + operand would convert to an integer outside the range of the + destination format, the invalid operation exception shall be + signaled if this situation cannot otherwise be indicated. */ if (REAL_VALUE_ISNAN (*x)) - return const0_rtx; + return flag_trapping_math ? NULL_RTX : const0_rtx; + + if (REAL_VALUE_ISINF (*x) && flag_trapping_math) + return NULL_RTX; /* Test against the signed upper bound. */ wmax = wi::max_value (width, SIGNED); real_from_integer (&t, VOIDmode, wmax, SIGNED); if (real_less (&t, x)) - return immed_wide_int_const (wmax, mode); + return (flag_trapping_math + ? NULL_RTX : immed_wide_int_const (wmax, mode)); /* Test against the signed lower bound. */ wmin = wi::min_value (width, SIGNED); @@ -2276,13 +2287,17 @@ simplify_const_unary_operation (enum rtx_code code, machine_mode mode, case UNSIGNED_FIX: if (REAL_VALUE_ISNAN (*x) || REAL_VALUE_NEGATIVE (*x)) - return const0_rtx; + return flag_trapping_math ? NULL_RTX : const0_rtx; + + if (REAL_VALUE_ISINF (*x) && flag_trapping_math) + return NULL_RTX; /* Test against the unsigned upper bound. */ wmax = wi::max_value (width, UNSIGNED); real_from_integer (&t, VOIDmode, wmax, UNSIGNED); if (real_less (&t, x)) - return immed_wide_int_const (wmax, mode); + return (flag_trapping_math + ? NULL_RTX : immed_wide_int_const (wmax, mode)); return immed_wide_int_const (real_to_integer (x, &fail, width),
next prev parent reply other threads:[~2024-05-22 1:06 UTC|newest] Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-05-20 10:07 [Bug target/115161] New: " slyfox at gcc dot gnu.org 2024-05-20 11:26 ` [Bug target/115161] " slyfox at gcc dot gnu.org 2024-05-20 14:48 ` roger at nextmovesoftware dot com 2024-05-20 22:08 ` slyfox at gcc dot gnu.org 2024-05-21 6:41 ` rguenth at gcc dot gnu.org 2024-05-21 14:53 ` jakub at gcc dot gnu.org 2024-05-21 15:02 ` jakub at gcc dot gnu.org 2024-05-21 15:13 ` jakub at gcc dot gnu.org 2024-05-21 15:40 ` amonakov at gcc dot gnu.org 2024-05-21 15:50 ` slyfox at gcc dot gnu.org 2024-05-21 15:51 ` jakub at gcc dot gnu.org 2024-05-21 16:07 ` jakub at gcc dot gnu.org 2024-05-22 1:06 ` liuhongt at gcc dot gnu.org [this message] 2024-05-22 1:13 ` pinskia at gcc dot gnu.org 2024-05-22 7:27 ` jakub at gcc dot gnu.org 2024-05-22 7:41 ` slyfox at gcc dot gnu.org 2024-05-22 7:43 ` slyfox at gcc dot gnu.org 2024-05-22 7:52 ` liuhongt at gcc dot gnu.org 2024-05-22 8:03 ` jakub at gcc dot gnu.org 2024-05-22 8:22 ` amonakov at gcc dot gnu.org 2024-05-22 8:26 ` jakub at gcc dot gnu.org 2024-05-22 8:49 ` amonakov at gcc dot gnu.org 2024-05-23 10:39 ` slyfox at gcc dot gnu.org 2024-05-24 22:00 ` slyfox at gcc dot gnu.org 2024-05-25 17:15 ` amonakov at gcc dot gnu.org 2024-05-25 18:44 ` slyfox at gcc dot gnu.org 2024-05-27 0:47 ` [Bug target/115161] highway-1.0.7 miscompilation of _mm_cvttps_epi32(): invalid result assumed liuhongt at gcc dot gnu.org 2024-06-05 4:09 ` cvs-commit at gcc dot gnu.org 2024-06-05 9:13 ` slyfox at gcc dot gnu.org 2024-06-17 8:17 ` cvs-commit 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-115161-4-l0t0V2HFrS@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: linkBe 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).