public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "tkoenig at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/103683] New: Redundant !__builtin_isnan not removed with -fno-signaling-nans Date: Mon, 13 Dec 2021 12:51:36 +0000 [thread overview] Message-ID: <bug-103683-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103683 Bug ID: 103683 Summary: Redundant !__builtin_isnan not removed with -fno-signaling-nans Product: gcc Version: 11.2.0 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: tkoenig at gcc dot gnu.org Target Milestone: --- If x is a NaN, then x > 1 will fail, so the __builtin_isnan function could be removed in comparisons like (!__builtin_isnan (x)) && x > 1 lwhen -fno-signaling-nans is in effect. Test case: #include <math.h> #include <stdio.h> _Bool foo (double x) { return (!__builtin_isnan (x)) && x > 1; } _Bool bar (double x) { return x > 1; } void chk(double x) { printf ("%f %x %x\n", x, foo(x), bar(x)); } int main() { chk(-1.0); chk(1.0); chk(2.9); chk(NAN); return 0; } With "gcc -fno-signaling-nans -S -O3 nan.c", one gets for foo foo: .seh_endprologue ucomisd %xmm0, %xmm0 jp .L3 comisd .LC0(%rip), %xmm0 seta %al ret and for bar bar: .seh_endprologue comisd .LC0(%rip), %xmm0 seta %al ret .seh_endproc
next reply other threads:[~2021-12-13 12:51 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-12-13 12:51 tkoenig at gcc dot gnu.org [this message] 2021-12-14 0:05 ` [Bug tree-optimization/103683] " 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-103683-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: 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).