[llvm] 870137d - [FPEnv] Address post-commit review comment for D71467
Ulrich Weigand via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 15 06:11:18 PST 2020
Author: Ulrich Weigand
Date: 2020-01-15T15:10:11+01:00
New Revision: 870137d207f7a5596206e2210183d911a9b06f9d
URL: https://github.com/llvm/llvm-project/commit/870137d207f7a5596206e2210183d911a9b06f9d
DIFF: https://github.com/llvm/llvm-project/commit/870137d207f7a5596206e2210183d911a9b06f9d.diff
LOG: [FPEnv] Address post-commit review comment for D71467
Remove a bit of code duplication between CreateFCmp and CreateFCmpS
by creating a shared helper function.
Added:
Modified:
llvm/include/llvm/IR/IRBuilder.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/IR/IRBuilder.h b/llvm/include/llvm/IR/IRBuilder.h
index a6252b298001..6006d74fc59d 100644
--- a/llvm/include/llvm/IR/IRBuilder.h
+++ b/llvm/include/llvm/IR/IRBuilder.h
@@ -2366,14 +2366,7 @@ class IRBuilder : public IRBuilderBase, public Inserter {
// Note that this
diff ers from CreateFCmpS only if IsFPConstrained is true.
Value *CreateFCmp(CmpInst::Predicate P, Value *LHS, Value *RHS,
const Twine &Name = "", MDNode *FPMathTag = nullptr) {
- if (IsFPConstrained)
- return CreateConstrainedFPCmp(Intrinsic::experimental_constrained_fcmp,
- P, LHS, RHS, Name);
-
- if (auto *LC = dyn_cast<Constant>(LHS))
- if (auto *RC = dyn_cast<Constant>(RHS))
- return Insert(Folder.CreateFCmp(P, LC, RC), Name);
- return Insert(setFPAttrs(new FCmpInst(P, LHS, RHS), FPMathTag, FMF), Name);
+ return CreateFCmpHelper(P, LHS, RHS, Name, FPMathTag, false);
}
// Create a signaling floating-point comparison (i.e. one that raises an FP
@@ -2381,9 +2374,19 @@ class IRBuilder : public IRBuilderBase, public Inserter {
// Note that this
diff ers from CreateFCmp only if IsFPConstrained is true.
Value *CreateFCmpS(CmpInst::Predicate P, Value *LHS, Value *RHS,
const Twine &Name = "", MDNode *FPMathTag = nullptr) {
- if (IsFPConstrained)
- return CreateConstrainedFPCmp(Intrinsic::experimental_constrained_fcmps,
- P, LHS, RHS, Name);
+ return CreateFCmpHelper(P, LHS, RHS, Name, FPMathTag, true);
+ }
+
+private:
+ // Helper routine to create either a signaling or a quiet FP comparison.
+ Value *CreateFCmpHelper(CmpInst::Predicate P, Value *LHS, Value *RHS,
+ const Twine &Name, MDNode *FPMathTag,
+ bool IsSignaling) {
+ if (IsFPConstrained) {
+ auto ID = IsSignaling ? Intrinsic::experimental_constrained_fcmps
+ : Intrinsic::experimental_constrained_fcmp;
+ return CreateConstrainedFPCmp(ID, P, LHS, RHS, Name);
+ }
if (auto *LC = dyn_cast<Constant>(LHS))
if (auto *RC = dyn_cast<Constant>(RHS))
@@ -2391,6 +2394,7 @@ class IRBuilder : public IRBuilderBase, public Inserter {
return Insert(setFPAttrs(new FCmpInst(P, LHS, RHS), FPMathTag, FMF), Name);
}
+public:
CallInst *CreateConstrainedFPCmp(
Intrinsic::ID ID, CmpInst::Predicate P, Value *L, Value *R,
const Twine &Name = "",
More information about the llvm-commits
mailing list