[clang] 4bd3427 - IRBuilder: Add FMFSource parameter to CreateMaxNum/CreateMinNum (#129173)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 3 16:49:39 PST 2025
Author: YunQiang Su
Date: 2025-03-04T08:49:35+08:00
New Revision: 4bd34273210329047a7829f1ea4f54c171000c68
URL: https://github.com/llvm/llvm-project/commit/4bd34273210329047a7829f1ea4f54c171000c68
DIFF: https://github.com/llvm/llvm-project/commit/4bd34273210329047a7829f1ea4f54c171000c68.diff
LOG: IRBuilder: Add FMFSource parameter to CreateMaxNum/CreateMinNum (#129173)
In https://github.com/llvm/llvm-project/pull/112852, we claimed that
llvm.minnum and llvm.maxnum should treat +0.0>-0.0, while libc doesn't
require fmin(3)/fmax(3) for it.
Let's add FMFSource parameter to CreateMaxNum and CreateMinNum, so that
they can be used by CodeGenFunction::EmitBuiltinExpr of Clang.
Added:
Modified:
clang/lib/CodeGen/CGBuiltin.cpp
llvm/include/llvm/IR/IRBuilder.h
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 03b8d16b76e0d..ab8f19b25fa66 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -4378,7 +4378,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
: llvm::Intrinsic::umax,
Op0, Op1, nullptr, "elt.max");
} else
- Result = Builder.CreateMaxNum(Op0, Op1, "elt.max");
+ Result = Builder.CreateMaxNum(Op0, Op1, /*FMFSource=*/nullptr, "elt.max");
return RValue::get(Result);
}
case Builtin::BI__builtin_elementwise_min: {
@@ -4394,7 +4394,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
: llvm::Intrinsic::umin,
Op0, Op1, nullptr, "elt.min");
} else
- Result = Builder.CreateMinNum(Op0, Op1, "elt.min");
+ Result = Builder.CreateMinNum(Op0, Op1, /*FMFSource=*/nullptr, "elt.min");
return RValue::get(Result);
}
diff --git a/llvm/include/llvm/IR/IRBuilder.h b/llvm/include/llvm/IR/IRBuilder.h
index 933dbb306d1fc..67e357c600d3b 100644
--- a/llvm/include/llvm/IR/IRBuilder.h
+++ b/llvm/include/llvm/IR/IRBuilder.h
@@ -1005,23 +1005,27 @@ class IRBuilderBase {
const Twine &Name = "");
/// Create call to the minnum intrinsic.
- Value *CreateMinNum(Value *LHS, Value *RHS, const Twine &Name = "") {
+ Value *CreateMinNum(Value *LHS, Value *RHS, FMFSource FMFSource = {},
+ const Twine &Name = "") {
if (IsFPConstrained) {
return CreateConstrainedFPUnroundedBinOp(
- Intrinsic::experimental_constrained_minnum, LHS, RHS, nullptr, Name);
+ Intrinsic::experimental_constrained_minnum, LHS, RHS, FMFSource,
+ Name);
}
- return CreateBinaryIntrinsic(Intrinsic::minnum, LHS, RHS, nullptr, Name);
+ return CreateBinaryIntrinsic(Intrinsic::minnum, LHS, RHS, FMFSource, Name);
}
/// Create call to the maxnum intrinsic.
- Value *CreateMaxNum(Value *LHS, Value *RHS, const Twine &Name = "") {
+ Value *CreateMaxNum(Value *LHS, Value *RHS, FMFSource FMFSource = {},
+ const Twine &Name = "") {
if (IsFPConstrained) {
return CreateConstrainedFPUnroundedBinOp(
- Intrinsic::experimental_constrained_maxnum, LHS, RHS, nullptr, Name);
+ Intrinsic::experimental_constrained_maxnum, LHS, RHS, FMFSource,
+ Name);
}
- return CreateBinaryIntrinsic(Intrinsic::maxnum, LHS, RHS, nullptr, Name);
+ return CreateBinaryIntrinsic(Intrinsic::maxnum, LHS, RHS, FMFSource, Name);
}
/// Create call to the minimum intrinsic.
More information about the cfe-commits
mailing list