public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "linkw at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug target/105480] Vectorized `isnan` appears to trigger FPE on ppc64le Date: Wed, 09 Nov 2022 08:31:03 +0000 [thread overview] Message-ID: <bug-105480-4-kwT8606soC@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-105480-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105480 Kewen Lin <linkw at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bergner at gcc dot gnu.org, | |jsm28 at gcc dot gnu.org, | |rguenth at gcc dot gnu.org, | |rsandifo at gcc dot gnu.org, | |segher at gcc dot gnu.org --- Comment #6 from Kewen Lin <linkw at gcc dot gnu.org> --- It's certainly an issue reported here, for one complete fix I did some more investigation how the option -ftrapping-math affects things, from what LLVM generates, it looks to me that: 1) with -ftrapping-math, we can assume fp operations can raise exceptions (user visible as doc said), here __builtin_isnan should not raise exception even for sNaN, so it uses vector int instructions instead. 2) while with -fno-trapping-math, we can assume fp operations can't raise exceptions, and as doc said "This option requires that -fno-signaling-nans be in effect", so there is no sNaN at all, safe to use vector fp instructions which don't trap for qNaN. It's concluded that __builtin_isnan is supposed not to trap even if the given value is sNaN. But with one simple scalar version of case with __builtin_isnan, I don't see GCC honor -ftrapping-math from the code generated on both Power and aarch64: ---- #define _GNU_SOURCE #include "math.h" int func(double x) { return __builtin_isnan (x); } ---- w/ -ftrapping-math or -fno-trapping-math, it gets the same insns like: aarch64: fcmp d0, d0 cset w0, vs ret ppc64le: fcmpu 0,1,1 mfcr 3,128 rlwinm 3,3,4,1 Both fcmpu and fcmp would trap for sNaN, is it expected with the current GCC implementation? Tested with compiler explorer, I saw LLVM generates insns without fcmpu on Power, like: mffprd 4, 1 li 3, 2047 rldic 3, 3, 52, 1 clrldi 4, 4, 1 subc 4, 3, 4 subfe 3, 3, 3 neg 3, 3 blr though I did still see LLVM uses fcmp on aarch64 (maybe a warning saying "overriding currently unsupported use of floating point exceptions on this target" can explain it). Another question in mind is that I saw GCC lowed __builtin_isnan with tree code UNORDERED_EXPR, does it mean that UNORDERED_EXPR has the same semantic as what's concluded for __builtin_isnan above (that is not to trap for both qNaN and sNaN)? It seems internal documentation doesn't say much on this.
next prev parent reply other threads:[~2022-11-09 8:31 UTC|newest] Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-05-04 13:15 [Bug target/105480] New: " sebastian-gcc at sipsolutions dot net 2022-05-04 14:21 ` [Bug target/105480] " sebastian-gcc at sipsolutions dot net 2022-05-05 8:14 ` sebastian-gcc at sipsolutions dot net 2022-11-02 20:00 ` pinskia at gcc dot gnu.org 2022-11-02 20:10 ` pinskia at gcc dot gnu.org 2022-11-08 7:14 ` linkw at gcc dot gnu.org 2022-11-09 8:31 ` linkw at gcc dot gnu.org [this message] 2022-11-09 8:48 ` rguenth at gcc dot gnu.org 2022-11-09 8:59 ` linkw at gcc dot gnu.org 2022-11-09 13:08 ` rguenth at gcc dot gnu.org 2022-11-09 17:30 ` joseph at codesourcery dot com 2022-11-10 5:58 ` linkw at gcc dot gnu.org 2022-11-10 23:42 ` joseph at codesourcery 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-105480-4-kwT8606soC@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).