From a25d5dcb4d84124ce525777bd1ff209bb5d0a8ce Mon Sep 17 00:00:00 2001 From: YunQiang Su Date: Mon, 28 Apr 2025 08:54:40 +0800 Subject: [PATCH 1/2] LangRef: Clarify nsz on min/max operations for +0.0 vs -0.0 On min/max operations, now +0.0 is treated greater than -0.0. To ignore this behaivor (fmin/fmax of libc doesn't require it), let's use `nsz` for this case. --- llvm/docs/LangRef.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst index 5bd1d29487139..12d5a7fe8c419 100644 --- a/llvm/docs/LangRef.rst +++ b/llvm/docs/LangRef.rst @@ -3914,6 +3914,10 @@ following flags to enable otherwise unsafe floating-point transformations. No Signed Zeros - Allow optimizations to treat the sign of a zero argument or zero result as insignificant. This does not imply that -0.0 is poison and/or guaranteed to not exist in the operation. + Don't require +0.0>-0.0 for min/max operations - Allow optimizations of the + min/max operation not to treat +0.0>-0.0. Note the result should be either of + the operands. (max|min)(-0.0, -0.0) should never return +0.0, and vice versa. + Note: floating compare operations always imply -0.0 == +0.0. Note: For :ref:`phi `, :ref:`select `, and :ref:`call ` instructions, the following return types are considered to be floating-point From 918e5ace424288661b666d255b8419319359de7e Mon Sep 17 00:00:00 2001 From: YunQiang Su Date: Thu, 8 May 2025 09:36:01 +0800 Subject: [PATCH 2/2] Rewording --- llvm/docs/LangRef.rst | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst index 12d5a7fe8c419..6f2a1b6c9ee3b 100644 --- a/llvm/docs/LangRef.rst +++ b/llvm/docs/LangRef.rst @@ -3914,10 +3914,11 @@ following flags to enable otherwise unsafe floating-point transformations. No Signed Zeros - Allow optimizations to treat the sign of a zero argument or zero result as insignificant. This does not imply that -0.0 is poison and/or guaranteed to not exist in the operation. - Don't require +0.0>-0.0 for min/max operations - Allow optimizations of the - min/max operation not to treat +0.0>-0.0. Note the result should be either of - the operands. (max|min)(-0.0, -0.0) should never return +0.0, and vice versa. - Note: floating compare operations always imply -0.0 == +0.0. + For fcmp, this has no effect. For min/max intrinsics, this allows + returning either +0 or -0 if both +0 and -0 are passed. + For calls to anything other than a min/max intrinsic, + arithmetic instructions, select, and phi, if the result is zero, + the returned value can be a zero of either sign. Note: For :ref:`phi `, :ref:`select `, and :ref:`call ` instructions, the following return types are considered to be floating-point