[llvm] LangRef: Clarify nsz on min/max operations for +0.0 vs -0.0 (PR #137567)

YunQiang Su via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 27 18:00:42 PDT 2025


https://github.com/wzssyqa created https://github.com/llvm/llvm-project/pull/137567

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.

>From a25d5dcb4d84124ce525777bd1ff209bb5d0a8ce Mon Sep 17 00:00:00 2001
From: YunQiang Su <yunqiang at isrc.iscas.ac.cn>
Date: Mon, 28 Apr 2025 08:54:40 +0800
Subject: [PATCH] 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 <i_phi>`, :ref:`select <i_select>`, and :ref:`call <i_call>`
 instructions, the following return types are considered to be floating-point



More information about the llvm-commits mailing list