Skip to content

Commit df3fd41

Browse files
committed
IRBuilder: Add FastMathFlags parameter to CreateMaxNum/CreateMinNum
In #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 FastMathFlags parameter to CreateMaxNum and CreateMinNum, so that it can be used by CodeGenFunction::EmitBuiltinExpr of Clang.
1 parent 88ff607 commit df3fd41

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

llvm/include/llvm/IR/IRBuilder.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,23 +1005,27 @@ class IRBuilderBase {
10051005
const Twine &Name = "");
10061006

10071007
/// Create call to the minnum intrinsic.
1008-
Value *CreateMinNum(Value *LHS, Value *RHS, const Twine &Name = "") {
1008+
Value *CreateMinNum(Value *LHS, Value *RHS, const Twine &Name = "",
1009+
FastMathFlags FMF = {}) {
1010+
FMFSource FMFSrc(FMF);
10091011
if (IsFPConstrained) {
10101012
return CreateConstrainedFPUnroundedBinOp(
1011-
Intrinsic::experimental_constrained_minnum, LHS, RHS, nullptr, Name);
1013+
Intrinsic::experimental_constrained_minnum, LHS, RHS, FMFSrc, Name);
10121014
}
10131015

1014-
return CreateBinaryIntrinsic(Intrinsic::minnum, LHS, RHS, nullptr, Name);
1016+
return CreateBinaryIntrinsic(Intrinsic::minnum, LHS, RHS, FMFSrc, Name);
10151017
}
10161018

10171019
/// Create call to the maxnum intrinsic.
1018-
Value *CreateMaxNum(Value *LHS, Value *RHS, const Twine &Name = "") {
1020+
Value *CreateMaxNum(Value *LHS, Value *RHS, const Twine &Name = "",
1021+
FastMathFlags FMF = {}) {
1022+
FMFSource FMFSrc(FMF);
10191023
if (IsFPConstrained) {
10201024
return CreateConstrainedFPUnroundedBinOp(
1021-
Intrinsic::experimental_constrained_maxnum, LHS, RHS, nullptr, Name);
1025+
Intrinsic::experimental_constrained_maxnum, LHS, RHS, FMFSrc, Name);
10221026
}
10231027

1024-
return CreateBinaryIntrinsic(Intrinsic::maxnum, LHS, RHS, nullptr, Name);
1028+
return CreateBinaryIntrinsic(Intrinsic::maxnum, LHS, RHS, FMFSrc, Name);
10251029
}
10261030

10271031
/// Create call to the minimum intrinsic.

0 commit comments

Comments
 (0)