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

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 8 23:16:38 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);
----------------
nikic wrote:

I think `__builtin_elementwise_min` must be changed to use `minimumnum` semantics to be coherent now. The new `minnum` semantics are non-associative, so an elementwise minnum is no longer a well-defined operation. It would have to specify an explicit reduction order, which requires a different intrinsic design (see the signature differences between reduce.fadd and reduce.fmin).

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


More information about the llvm-commits mailing list