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

via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 27 18:01:20 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-ir

Author: YunQiang Su (wzssyqa)

<details>
<summary>Changes</summary>

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.

---
Full diff: https://github.com/llvm/llvm-project/pull/137567.diff


1 Files Affected:

- (modified) llvm/docs/LangRef.rst (+4) 


``````````diff
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

``````````

</details>


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


More information about the llvm-commits mailing list