This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH v2 1/9] Document signaling for min, max and ltgt operations
- From: Ilya Leoshkevich <iii at linux dot ibm dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: richard dot sandiford at arm dot com, segher at kernel dot crashing dot org, Ilya Leoshkevich <iii at linux dot ibm dot com>
- Date: Thu, 22 Aug 2019 15:45:43 +0200
- Subject: [PATCH v2 1/9] Document signaling for min, max and ltgt operations
- References: <20190822134551.18924-1-iii@linux.ibm.com>
Currently it's not clear whether min, max and ltgt should raise floating
point exceptions when dealing with qNaNs.
Right now a lot of code assumes that LTGT is signaling: in particular,
with -fno-finite-math-only, which is the default, it's generated for
the signaling ((x < y) || (x > y)).
The behavior of MIN/MAX is (intentionally?) left unspecified, according
to https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=263751
("Unconditionally use MAX_EXPR/MIN_EXPR for MAX/MIN intrinsics").
So document the status quo.
gcc/ChangeLog:
2019-08-09 Ilya Leoshkevich <iii@linux.ibm.com>
PR target/91323
* doc/generic.texi (LTGT_EXPR): Restore the original wording
regarding floating point exceptions.
(MIN_EXPR, MAX_EXPR): Document.
* doc/md.texi (smin, smax): Add a clause regarding floating
point exceptions.
* doc/rtl.texi (smin, smax): Add a clause regarding floating
point exceptions.
---
gcc/doc/generic.texi | 16 +++++++++++++---
gcc/doc/md.texi | 3 ++-
gcc/doc/rtl.texi | 3 ++-
3 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/gcc/doc/generic.texi b/gcc/doc/generic.texi
index 8901d5f357e..d5ae20bd461 100644
--- a/gcc/doc/generic.texi
+++ b/gcc/doc/generic.texi
@@ -1331,6 +1331,8 @@ the byte offset of the field, but should not be used directly; call
@tindex UNGE_EXPR
@tindex UNEQ_EXPR
@tindex LTGT_EXPR
+@tindex MIN_EXPR
+@tindex MAX_EXPR
@tindex MODIFY_EXPR
@tindex INIT_EXPR
@tindex COMPOUND_EXPR
@@ -1602,13 +1604,21 @@ These operations take two floating point operands and determine whether
the operands are unordered or are less than, less than or equal to,
greater than, greater than or equal to, or equal respectively. For
example, @code{UNLT_EXPR} returns true if either operand is an IEEE
-NaN or the first operand is less than the second. With the possible
-exception of @code{LTGT_EXPR}, all of these operations are guaranteed
-not to generate a floating point exception. The result
+NaN or the first operand is less than the second. Only @code{LTGT_EXPR}
+is expected to raise an invalid floating-point-operation trap when the
+outcome is unordered. All other operations are guaranteed not to raise
+a floating point exception. The result
type of these expressions will always be of integral or boolean type.
These operations return the result type's zero value for false,
and the result type's one value for true.
+@item MIN_EXPR
+@itemx MAX_EXPR
+These nodes represent minimum and maximum operations. When used with
+floating point, if both operands are zeros, or if either operand is
+@code{NaN}, then it is unspecified which of the two operands is returned
+as the result and whether or not a floating point exception is raised.
+
@item MODIFY_EXPR
These nodes represent assignment. The left-hand side is the first
operand; the right-hand side is the second operand. The left-hand side
diff --git a/gcc/doc/md.texi b/gcc/doc/md.texi
index 7751984bf5f..74f8ec84974 100644
--- a/gcc/doc/md.texi
+++ b/gcc/doc/md.texi
@@ -5353,7 +5353,8 @@ in the rtl as
@item @samp{smin@var{m}3}, @samp{smax@var{m}3}
Signed minimum and maximum operations. When used with floating point,
if both operands are zeros, or if either operand is @code{NaN}, then
-it is unspecified which of the two operands is returned as the result.
+it is unspecified which of the two operands is returned as the result
+and whether or not a floating point exception is raised.
@cindex @code{fmin@var{m}3} instruction pattern
@cindex @code{fmax@var{m}3} instruction pattern
diff --git a/gcc/doc/rtl.texi b/gcc/doc/rtl.texi
index 0814b66a486..e0628da893d 100644
--- a/gcc/doc/rtl.texi
+++ b/gcc/doc/rtl.texi
@@ -2596,7 +2596,8 @@ Represents the smaller (for @code{smin}) or larger (for @code{smax}) of
@var{x} and @var{y}, interpreted as signed values in mode @var{m}.
When used with floating point, if both operands are zeros, or if either
operand is @code{NaN}, then it is unspecified which of the two operands
-is returned as the result.
+is returned as the result and whether or not a floating point exception
+is raised.
@findex umin
@findex umax
--
2.21.0