Skip to content

Commit 1c4a946

Browse files
committed
IRBuilder: Add NoSignedZeros 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 NoSignedZeros parameter to CreateMaxNum and CreateMinNum, so that they can used by CodeGenFunction::EmitBuiltinExpr of Clang.
1 parent 88ff607 commit 1c4a946

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

llvm/include/llvm/IR/IRBuilder.h

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,23 +1005,31 @@ 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+
bool NoSignedZeros = false) {
1010+
llvm::FastMathFlags FMF;
1011+
FMF.setNoSignedZeros(NoSignedZeros);
1012+
FMFSource FMFSrc(FMF);
10091013
if (IsFPConstrained) {
10101014
return CreateConstrainedFPUnroundedBinOp(
1011-
Intrinsic::experimental_constrained_minnum, LHS, RHS, nullptr, Name);
1015+
Intrinsic::experimental_constrained_minnum, LHS, RHS, FMFSrc, Name);
10121016
}
10131017

1014-
return CreateBinaryIntrinsic(Intrinsic::minnum, LHS, RHS, nullptr, Name);
1018+
return CreateBinaryIntrinsic(Intrinsic::minnum, LHS, RHS, FMFSrc, Name);
10151019
}
10161020

10171021
/// Create call to the maxnum intrinsic.
1018-
Value *CreateMaxNum(Value *LHS, Value *RHS, const Twine &Name = "") {
1022+
Value *CreateMaxNum(Value *LHS, Value *RHS, const Twine &Name = "",
1023+
bool NoSignedZeros = false) {
1024+
llvm::FastMathFlags FMF;
1025+
FMF.setNoSignedZeros(NoSignedZeros);
1026+
FMFSource FMFSrc(FMF);
10191027
if (IsFPConstrained) {
10201028
return CreateConstrainedFPUnroundedBinOp(
1021-
Intrinsic::experimental_constrained_maxnum, LHS, RHS, nullptr, Name);
1029+
Intrinsic::experimental_constrained_maxnum, LHS, RHS, FMFSrc, Name);
10221030
}
10231031

1024-
return CreateBinaryIntrinsic(Intrinsic::maxnum, LHS, RHS, nullptr, Name);
1032+
return CreateBinaryIntrinsic(Intrinsic::maxnum, LHS, RHS, FMFSrc, Name);
10251033
}
10261034

10271035
/// Create call to the minimum intrinsic.

0 commit comments

Comments
 (0)