[llvm] LangRef: Clarify nsz on min/max operations for +0.0 vs -0.0 (PR #137567)
Eli Friedman via llvm-commits
llvm-commits at lists.llvm.org
Wed May 7 12:53:18 PDT 2025
================
@@ -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.
----------------
efriedma-quic wrote:
> When we expand the fmin(3) and fmax(3) libc calls, we need something like nsz here.
That's not what I was asking; do we have "generic" optimizations that query nsz, besides the ones that are specific to min/max?
> We already do this:
I'm not saying there's anything missing, exactly, I just think it needs to be reorganized. Like, "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."
https://github.com/llvm/llvm-project/pull/137567
More information about the llvm-commits
mailing list