-
Notifications
You must be signed in to change notification settings - Fork 13.6k
IRBuilder: Add FMFSource parameter to CreateMaxNum/CreateMinNum #129173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-clang-codegen @llvm/pr-subscribers-llvm-ir Author: YunQiang Su (wzssyqa) ChangesIn #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. Full diff: https://github.com/llvm/llvm-project/pull/129173.diff 1 Files Affected:
diff --git a/llvm/include/llvm/IR/IRBuilder.h b/llvm/include/llvm/IR/IRBuilder.h
index 933dbb306d1fc..fe8c269101847 100644
--- a/llvm/include/llvm/IR/IRBuilder.h
+++ b/llvm/include/llvm/IR/IRBuilder.h
@@ -1005,23 +1005,31 @@ 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, const Twine &Name = "",
+ bool NoSignedZeros = false) {
+ llvm::FastMathFlags FMF;
+ FMF.setNoSignedZeros(NoSignedZeros);
+ FMFSource FMFSrc(FMF);
if (IsFPConstrained) {
return CreateConstrainedFPUnroundedBinOp(
- Intrinsic::experimental_constrained_minnum, LHS, RHS, nullptr, Name);
+ Intrinsic::experimental_constrained_minnum, LHS, RHS, FMFSrc, Name);
}
- return CreateBinaryIntrinsic(Intrinsic::minnum, LHS, RHS, nullptr, Name);
+ return CreateBinaryIntrinsic(Intrinsic::minnum, LHS, RHS, FMFSrc, Name);
}
/// Create call to the maxnum intrinsic.
- Value *CreateMaxNum(Value *LHS, Value *RHS, const Twine &Name = "") {
+ Value *CreateMaxNum(Value *LHS, Value *RHS, const Twine &Name = "",
+ bool NoSignedZeros = false) {
+ llvm::FastMathFlags FMF;
+ FMF.setNoSignedZeros(NoSignedZeros);
+ FMFSource FMFSrc(FMF);
if (IsFPConstrained) {
return CreateConstrainedFPUnroundedBinOp(
- Intrinsic::experimental_constrained_maxnum, LHS, RHS, nullptr, Name);
+ Intrinsic::experimental_constrained_maxnum, LHS, RHS, FMFSrc, Name);
}
- return CreateBinaryIntrinsic(Intrinsic::maxnum, LHS, RHS, nullptr, Name);
+ return CreateBinaryIntrinsic(Intrinsic::maxnum, LHS, RHS, FMFSrc, Name);
}
/// Create call to the minimum intrinsic.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should add a general FastMathFlags argument
1c4a946
to
df3fd41
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should follow the precedent set by #121657 and use FMFSource
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 it can be used by CodeGenFunction::EmitBuiltinExpr of Clang.
df3fd41
to
de75517
Compare
✅ With the latest revision this PR passed the C/C++ code formatter. |
…#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.
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 FMFSource parameter to CreateMaxNum and CreateMinNum, so that they can be used by CodeGenFunction::EmitBuiltinExpr of Clang.