public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/88173] `std::numeric_limits<T>::quiet_NaN()` is not always constexpr
[not found] <bug-88173-4@http.gcc.gnu.org/bugzilla/>
@ 2020-12-08 18:52 ` jason at gcc dot gnu.org
2020-12-08 19:47 ` [Bug middle-end/88173] constant folding of NaN comparison depends on order of operands jason at gcc dot gnu.org
` (6 subsequent siblings)
7 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu.org @ 2020-12-08 18:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88173
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
Last reconfirmed| |2020-12-08
CC| |jason at gcc dot gnu.org
--- Comment #10 from Jason Merrill <jason at gcc dot gnu.org> ---
Shorter:
#define inf __builtin_huge_val()
#define nan __builtin_nan("")
constexpr bool b1 = inf > nan; // OK
constexpr bool b2 = nan < inf; // ‘(+QNaN <= 1.7976931348623157e+308)’ is not a
constant expression
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug middle-end/88173] constant folding of NaN comparison depends on order of operands
[not found] <bug-88173-4@http.gcc.gnu.org/bugzilla/>
2020-12-08 18:52 ` [Bug c++/88173] `std::numeric_limits<T>::quiet_NaN()` is not always constexpr jason at gcc dot gnu.org
@ 2020-12-08 19:47 ` jason at gcc dot gnu.org
2020-12-08 20:48 ` jakub at gcc dot gnu.org
` (5 subsequent siblings)
7 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu.org @ 2020-12-08 19:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88173
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|`std::numeric_limits<T>::qu |constant folding of NaN
|iet_NaN()` is not always |comparison depends on order
|constexpr |of operands
Component|c++ |middle-end
--- Comment #11 from Jason Merrill <jason at gcc dot gnu.org> ---
Middle-end issue; the patterns in match.pd handle these equivalent comparisons
very differently.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug middle-end/88173] constant folding of NaN comparison depends on order of operands
[not found] <bug-88173-4@http.gcc.gnu.org/bugzilla/>
2020-12-08 18:52 ` [Bug c++/88173] `std::numeric_limits<T>::quiet_NaN()` is not always constexpr jason at gcc dot gnu.org
2020-12-08 19:47 ` [Bug middle-end/88173] constant folding of NaN comparison depends on order of operands jason at gcc dot gnu.org
@ 2020-12-08 20:48 ` jakub at gcc dot gnu.org
2021-09-18 8:58 ` roger at nextmovesoftware dot com
` (4 subsequent siblings)
7 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-12-08 20:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88173
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #12 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
What should be the exact rules for C++ floating point evaluation that trigger
non-constant expressions? And shall that depend (like it partly does for GCC
currently) on e.g. -ftrapping-math and other command line options?
1.0 / 0.0 - division by zero (for floating point results in Inf)
10000000000000.0 + 0.000000000000001 - inexact (hope this one not)
inf - inf - invalid - non-NaN operands resulting in NaN result
sqrt (-1) - likewise
DBL_MAX * DBL_MAX - overflow
DBL_MIN * DBL_MIN - underflow
NaN + 1.0 - one or both operands NaN resulting in NaN
sNaN + 1.0 - at least one operand sNaN
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug middle-end/88173] constant folding of NaN comparison depends on order of operands
[not found] <bug-88173-4@http.gcc.gnu.org/bugzilla/>
` (2 preceding siblings ...)
2020-12-08 20:48 ` jakub at gcc dot gnu.org
@ 2021-09-18 8:58 ` roger at nextmovesoftware dot com
2021-09-19 8:08 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
7 siblings, 0 replies; 8+ messages in thread
From: roger at nextmovesoftware dot com @ 2021-09-18 8:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88173
Roger Sayle <roger at nextmovesoftware dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |roger at nextmovesoftware dot com
CC| |roger at nextmovesoftware dot com
Status|NEW |ASSIGNED
--- Comment #13 from Roger Sayle <roger at nextmovesoftware dot com> ---
Patch proposed.
https://gcc.gnu.org/pipermail/gcc-patches/2021-September/579747.html
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug middle-end/88173] constant folding of NaN comparison depends on order of operands
[not found] <bug-88173-4@http.gcc.gnu.org/bugzilla/>
` (3 preceding siblings ...)
2021-09-18 8:58 ` roger at nextmovesoftware dot com
@ 2021-09-19 8:08 ` cvs-commit at gcc dot gnu.org
2021-09-19 21:42 ` roger at nextmovesoftware dot com
` (2 subsequent siblings)
7 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-09-19 8:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88173
--- Comment #14 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Roger Sayle <sayle@gcc.gnu.org>:
https://gcc.gnu.org/g:e9e46864cd0695d2dcec5c513f249b1e1ab0056f
commit r12-3660-ge9e46864cd0695d2dcec5c513f249b1e1ab0056f
Author: Roger Sayle <roger@nextmovesoftware.com>
Date: Sun Sep 19 09:07:01 2021 +0100
PR middle-end/88173: More constant folding of NaN comparisons.
This patch tackles PR middle-end/88173 where the order of operands in
a comparison affects constant folding. As diagnosed by Jason Merrill,
"match.pd handles these comparisons very differently". The history is
that the middle end, typically canonicalizes comparisons to place
constants on the right, but when a comparison contains two constants
we need to check/transform both constants, i.e. on both the left and the
right. Hence the added lines below duplicate for @0 the same transform
applied a few lines above for @1.
Whilst preparing the testcase, I noticed that this transformation is
incorrectly disabled with -fsignaling-nans even when both operands are
known not be be signaling NaNs, so I've corrected that and added a
second test case. Unfortunately, c-c++-common/pr57371-4.c then starts
failing, as it doesn't distinguish QNaNs (which are quiet) from SNaNs
(which signal), so this patch includes a minor tweak to the expected
behaviour for QNaNs in that existing test.
2021-09-19 Roger Sayle <roger@nextmovesoftware.com>
gcc/ChangeLog
PR middle-end/88173
* match.pd (cmp @0 REAL_CST@1): When @0 is also REAL_CST, apply
the same transformations as to @1. For comparisons against NaN,
don't check HONOR_SNANS but confirm that neither operand is a
signaling NaN.
gcc/testsuite/ChangeLog
PR middle-end/88173
* c-c++-common/pr57371-4.c: Tweak/correct test case for QNaNs.
* g++.dg/pr88173-1.C: New test case.
* g++.dg/pr88173-2.C: New test case.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug middle-end/88173] constant folding of NaN comparison depends on order of operands
[not found] <bug-88173-4@http.gcc.gnu.org/bugzilla/>
` (4 preceding siblings ...)
2021-09-19 8:08 ` cvs-commit at gcc dot gnu.org
@ 2021-09-19 21:42 ` roger at nextmovesoftware dot com
2021-11-08 10:01 ` pinskia at gcc dot gnu.org
2022-12-28 19:14 ` pinskia at gcc dot gnu.org
7 siblings, 0 replies; 8+ messages in thread
From: roger at nextmovesoftware dot com @ 2021-09-19 21:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88173
Roger Sayle <roger at nextmovesoftware dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |12.0
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
--- Comment #15 from Roger Sayle <roger at nextmovesoftware dot com> ---
This has been fixed on mainline.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug middle-end/88173] constant folding of NaN comparison depends on order of operands
[not found] <bug-88173-4@http.gcc.gnu.org/bugzilla/>
` (5 preceding siblings ...)
2021-09-19 21:42 ` roger at nextmovesoftware dot com
@ 2021-11-08 10:01 ` pinskia at gcc dot gnu.org
2022-12-28 19:14 ` pinskia at gcc dot gnu.org
7 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-08 10:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88173
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mjansche at google dot com
--- Comment #16 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 88683 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug middle-end/88173] constant folding of NaN comparison depends on order of operands
[not found] <bug-88173-4@http.gcc.gnu.org/bugzilla/>
` (6 preceding siblings ...)
2021-11-08 10:01 ` pinskia at gcc dot gnu.org
@ 2022-12-28 19:14 ` pinskia at gcc dot gnu.org
7 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-12-28 19:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88173
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jonas.rahlf.basf at gmail dot com
--- Comment #17 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 101795 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2022-12-28 19:14 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bug-88173-4@http.gcc.gnu.org/bugzilla/>
2020-12-08 18:52 ` [Bug c++/88173] `std::numeric_limits<T>::quiet_NaN()` is not always constexpr jason at gcc dot gnu.org
2020-12-08 19:47 ` [Bug middle-end/88173] constant folding of NaN comparison depends on order of operands jason at gcc dot gnu.org
2020-12-08 20:48 ` jakub at gcc dot gnu.org
2021-09-18 8:58 ` roger at nextmovesoftware dot com
2021-09-19 8:08 ` cvs-commit at gcc dot gnu.org
2021-09-19 21:42 ` roger at nextmovesoftware dot com
2021-11-08 10:01 ` pinskia at gcc dot gnu.org
2022-12-28 19:14 ` pinskia at gcc dot gnu.org
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).