@@ -2366,31 +2366,35 @@ class IRBuilder : public IRBuilderBase, public Inserter {
2366
2366
// Note that this differs from CreateFCmpS only if IsFPConstrained is true.
2367
2367
Value *CreateFCmp (CmpInst::Predicate P, Value *LHS, Value *RHS,
2368
2368
const Twine &Name = " " , MDNode *FPMathTag = nullptr ) {
2369
- if (IsFPConstrained)
2370
- return CreateConstrainedFPCmp (Intrinsic::experimental_constrained_fcmp,
2371
- P, LHS, RHS, Name);
2372
-
2373
- if (auto *LC = dyn_cast<Constant>(LHS))
2374
- if (auto *RC = dyn_cast<Constant>(RHS))
2375
- return Insert (Folder.CreateFCmp (P, LC, RC), Name);
2376
- return Insert (setFPAttrs (new FCmpInst (P, LHS, RHS), FPMathTag, FMF), Name);
2369
+ return CreateFCmpHelper (P, LHS, RHS, Name, FPMathTag, false );
2377
2370
}
2378
2371
2379
2372
// Create a signaling floating-point comparison (i.e. one that raises an FP
2380
2373
// exception whenever an input is any NaN, signaling or quiet).
2381
2374
// Note that this differs from CreateFCmp only if IsFPConstrained is true.
2382
2375
Value *CreateFCmpS (CmpInst::Predicate P, Value *LHS, Value *RHS,
2383
2376
const Twine &Name = " " , MDNode *FPMathTag = nullptr ) {
2384
- if (IsFPConstrained)
2385
- return CreateConstrainedFPCmp (Intrinsic::experimental_constrained_fcmps,
2386
- P, LHS, RHS, Name);
2377
+ return CreateFCmpHelper (P, LHS, RHS, Name, FPMathTag, true );
2378
+ }
2379
+
2380
+ private:
2381
+ // Helper routine to create either a signaling or a quiet FP comparison.
2382
+ Value *CreateFCmpHelper (CmpInst::Predicate P, Value *LHS, Value *RHS,
2383
+ const Twine &Name, MDNode *FPMathTag,
2384
+ bool IsSignaling) {
2385
+ if (IsFPConstrained) {
2386
+ auto ID = IsSignaling ? Intrinsic::experimental_constrained_fcmps
2387
+ : Intrinsic::experimental_constrained_fcmp;
2388
+ return CreateConstrainedFPCmp (ID, P, LHS, RHS, Name);
2389
+ }
2387
2390
2388
2391
if (auto *LC = dyn_cast<Constant>(LHS))
2389
2392
if (auto *RC = dyn_cast<Constant>(RHS))
2390
2393
return Insert (Folder.CreateFCmp (P, LC, RC), Name);
2391
2394
return Insert (setFPAttrs (new FCmpInst (P, LHS, RHS), FPMathTag, FMF), Name);
2392
2395
}
2393
2396
2397
+ public:
2394
2398
CallInst *CreateConstrainedFPCmp (
2395
2399
Intrinsic::ID ID, CmpInst::Predicate P, Value *L, Value *R,
2396
2400
const Twine &Name = " " ,
0 commit comments