[clang] [llvm] Clang: Add nsz to llvm.minnum and llvm.maxnum emitted from fmin and fmax (PR #113133)

YunQiang Su via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 8 21:55:17 PST 2025


================
@@ -4002,8 +4012,11 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
       Result = Builder.CreateBinaryIntrinsic(
           Ty->isSignedIntegerType() ? Intrinsic::smin : Intrinsic::umin, Op0,
           Op1, nullptr, "elt.min");
-    } else
-      Result = Builder.CreateMinNum(Op0, Op1, /*FMFSource=*/nullptr, "elt.min");
+    } else {
+      FastMathFlags FMF;
+      FMF.setNoSignedZeros(true);
----------------
wzssyqa wrote:

> But they are in fact, different operations. And you have many choices for which FP min/max.
> 
> Given this name doesn't have the historic fmin/fmax in it, I don't think this should take the fuzzy signed zero handling

You are right, since we have `__builtin_elementwise_max/__builtin_elementwise_min`, we should not add `nsz` to 
`maxnum/minnum`.

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


More information about the llvm-commits mailing list