public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Andrew Macleod <amacleod@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-5448] Do not try to logical fold floating point relations. Date: Fri, 27 Jan 2023 14:38:30 +0000 (GMT) [thread overview] Message-ID: <20230127143830.B2C883858C00@sourceware.org> (raw) https://gcc.gnu.org/g:ec5e99e95954fd629283a9c9572193dd95471fea commit r13-5448-gec5e99e95954fd629283a9c9572193dd95471fea Author: Andrew MacLeod <amacleod@redhat.com> Date: Wed Jan 25 11:13:23 2023 -0500 Do not try to logical fold floating point relations. relation_fold_and_or looks for relations among common operands feeding logical ands and ors. With no knowledge of NANs, it should not attempt to do this with floating point ssa names. PR tree-optimization/108447 gcc/ * gimple-range-fold.cc (old_using_range::relation_fold_and_or): Do not attempt to fold HONOR_NAN types. gcc/testsuite/ * gcc.dg/pr108447.c: New. Diff: --- gcc/gimple-range-fold.cc | 3 +++ gcc/testsuite/gcc.dg/pr108447.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/gcc/gimple-range-fold.cc b/gcc/gimple-range-fold.cc index 91eb6298254..9c5359a3fc6 100644 --- a/gcc/gimple-range-fold.cc +++ b/gcc/gimple-range-fold.cc @@ -1039,6 +1039,9 @@ fold_using_range::relation_fold_and_or (irange& lhs_range, gimple *s, if (!ssa1_dep1 || !ssa1_dep2 || !ssa2_dep1 || !ssa2_dep2) return; + if (HONOR_NANS (TREE_TYPE (ssa1_dep1))) + return; + // Make sure they are the same dependencies, and detect the order of the // relationship. bool reverse_op2 = true; diff --git a/gcc/testsuite/gcc.dg/pr108447.c b/gcc/testsuite/gcc.dg/pr108447.c new file mode 100644 index 00000000000..cfbaba6d0aa --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr108447.c @@ -0,0 +1,33 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +__attribute__((noipa)) int +foo (float x, float y) +{ + _Bool cmp1 = x <= y; + _Bool cmp2 = x >= y; + if (cmp1 && cmp2) + return 1; + else if (!cmp1 && !cmp2) + return -1; + return 0; +} + +int +main () +{ + if (foo (0.0f, __builtin_nanf ("")) != -1) + __builtin_abort (); + if (foo (__builtin_nanf (""), -42.0f) != -1) + __builtin_abort (); + if (foo (0.0f, -0.0f) != 1) + __builtin_abort (); + if (foo (42.0f, 42.0f) != 1) + __builtin_abort (); + if (foo (42.0f, -0.0f) != 0) + __builtin_abort (); + if (foo (0.0f, -42.0f) != 0) + __builtin_abort (); + return 0; +} +
reply other threads:[~2023-01-27 14:38 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20230127143830.B2C883858C00@sourceware.org \ --to=amacleod@gcc.gnu.org \ --cc=gcc-cvs@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).