Skip to content

Commit b95d4a5

Browse files
wzssyqajph-13
authored andcommitted
IRBuilder: Add FMFSource parameter to CreateMaxNum/CreateMinNum (llvm#129173)
In llvm#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.
1 parent d76654c commit b95d4a5

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4378,7 +4378,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
43784378
: llvm::Intrinsic::umax,
43794379
Op0, Op1, nullptr, "elt.max");
43804380
} else
4381-
Result = Builder.CreateMaxNum(Op0, Op1, "elt.max");
4381+
Result = Builder.CreateMaxNum(Op0, Op1, /*FMFSource=*/nullptr, "elt.max");
43824382
return RValue::get(Result);
43834383
}
43844384
case Builtin::BI__builtin_elementwise_min: {
@@ -4394,7 +4394,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
43944394
: llvm::Intrinsic::umin,
43954395
Op0, Op1, nullptr, "elt.min");
43964396
} else
4397-
Result = Builder.CreateMinNum(Op0, Op1, "elt.min");
4397+
Result = Builder.CreateMinNum(Op0, Op1, /*FMFSource=*/nullptr, "elt.min");
43984398
return RValue::get(Result);
43994399
}
44004400

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, FMFSource FMFSource = {},
1009+
const Twine &Name = "") {
10091010
if (IsFPConstrained) {
10101011
return CreateConstrainedFPUnroundedBinOp(
1011-
Intrinsic::experimental_constrained_minnum, LHS, RHS, nullptr, Name);
1012+
Intrinsic::experimental_constrained_minnum, LHS, RHS, FMFSource,
1013+
Name);
10121014
}
10131015

1014-
return CreateBinaryIntrinsic(Intrinsic::minnum, LHS, RHS, nullptr, Name);
1016+
return CreateBinaryIntrinsic(Intrinsic::minnum, LHS, RHS, FMFSource, 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, FMFSource FMFSource = {},
1021+
const Twine &Name = "") {
10191022
if (IsFPConstrained) {
10201023
return CreateConstrainedFPUnroundedBinOp(
1021-
Intrinsic::experimental_constrained_maxnum, LHS, RHS, nullptr, Name);
1024+
Intrinsic::experimental_constrained_maxnum, LHS, RHS, FMFSource,
1025+
Name);
10221026
}
10231027

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

10271031
/// Create call to the minimum intrinsic.

0 commit comments

Comments
 (0)