From: Ulrich Weigand Date: Wed, 15 Jan 2020 14:08:35 +0000 (+0100) Subject: [FPEnv] Address post-commit review comment for D71467 X-Git-Tag: llvmorg-12-init~17860 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=870137d207f7a5596206e2210183d911a9b06f9d;p=platform%2Fupstream%2Fllvm.git [FPEnv] Address post-commit review comment for D71467 Remove a bit of code duplication between CreateFCmp and CreateFCmpS by creating a shared helper function. --- diff --git a/llvm/include/llvm/IR/IRBuilder.h b/llvm/include/llvm/IR/IRBuilder.h index a6252b29..6006d74 100644 --- a/llvm/include/llvm/IR/IRBuilder.h +++ b/llvm/include/llvm/IR/IRBuilder.h @@ -2366,14 +2366,7 @@ public: // Note that this differs 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(LHS)) - if (auto *RC = dyn_cast(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 @@ public: // Note that this differs 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(LHS)) if (auto *RC = dyn_cast(RHS)) @@ -2391,6 +2394,7 @@ public: 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 = "",