Skip to content
This repository has been archived by the owner on Jan 1, 2023. It is now read-only.

Commit

Permalink
Simplify usage of setFPAttrs.
Browse files Browse the repository at this point in the history
In some cases using the return value of setFPAttrs simplifies the code.
In other cases it complicates the code with ugly casts, so stop doing
it. NFC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@375409 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
jayfoad committed Oct 21, 2019
1 parent efbf5db commit 4a92230
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions include/llvm/IR/IRBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -1461,7 +1461,7 @@ class IRBuilder : public IRBuilderBase, public Inserter {
if (Value *V = foldConstant(Opc, LHS, RHS, Name)) return V;
Instruction *BinOp = BinaryOperator::Create(Opc, LHS, RHS);
if (isa<FPMathOperator>(BinOp))
BinOp = setFPAttrs(BinOp, FPMathTag, FMF);
setFPAttrs(BinOp, FPMathTag, FMF);
return Insert(BinOp, Name);
}

Expand All @@ -1479,7 +1479,8 @@ class IRBuilder : public IRBuilderBase, public Inserter {

CallInst *C = CreateIntrinsic(ID, {L->getType()},
{L, R, RoundingV, ExceptV}, nullptr, Name);
return cast<CallInst>(setFPAttrs(C, FPMathTag, UseFMF));
setFPAttrs(C, FPMathTag, UseFMF);
return C;
}

Value *CreateNeg(Value *V, const Twine &Name = "",
Expand Down Expand Up @@ -1532,7 +1533,7 @@ class IRBuilder : public IRBuilderBase, public Inserter {
return Insert(Folder.CreateUnOp(Opc, VC), Name);
Instruction *UnOp = UnaryOperator::Create(Opc, V);
if (isa<FPMathOperator>(UnOp))
UnOp = setFPAttrs(UnOp, FPMathTag, FMF);
setFPAttrs(UnOp, FPMathTag, FMF);
return Insert(UnOp, Name);
}

Expand Down Expand Up @@ -2084,7 +2085,7 @@ class IRBuilder : public IRBuilderBase, public Inserter {
break;
}
if (isa<FPMathOperator>(C))
C = cast<CallInst>(setFPAttrs(C, FPMathTag, UseFMF));
setFPAttrs(C, FPMathTag, UseFMF);
return C;
}

Expand Down Expand Up @@ -2231,7 +2232,7 @@ class IRBuilder : public IRBuilderBase, public Inserter {
const Twine &Name = "") {
PHINode *Phi = PHINode::Create(Ty, NumReservedValues);
if (isa<FPMathOperator>(Phi))
Phi = cast<PHINode>(setFPAttrs(Phi, nullptr /* MDNode* */, FMF));
setFPAttrs(Phi, nullptr /* MDNode* */, FMF);
return Insert(Phi, Name);
}

Expand All @@ -2240,7 +2241,7 @@ class IRBuilder : public IRBuilderBase, public Inserter {
MDNode *FPMathTag = nullptr) {
CallInst *CI = CallInst::Create(FTy, Callee, Args, DefaultOperandBundles);
if (isa<FPMathOperator>(CI))
CI = cast<CallInst>(setFPAttrs(CI, FPMathTag, FMF));
setFPAttrs(CI, FPMathTag, FMF);
return Insert(CI, Name);
}

Expand All @@ -2249,7 +2250,7 @@ class IRBuilder : public IRBuilderBase, public Inserter {
const Twine &Name = "", MDNode *FPMathTag = nullptr) {
CallInst *CI = CallInst::Create(FTy, Callee, Args, OpBundles);
if (isa<FPMathOperator>(CI))
CI = cast<CallInst>(setFPAttrs(CI, FPMathTag, FMF));
setFPAttrs(CI, FPMathTag, FMF);
return Insert(CI, Name);
}

Expand Down Expand Up @@ -2297,7 +2298,7 @@ class IRBuilder : public IRBuilderBase, public Inserter {
Sel = addBranchMetadata(Sel, Prof, Unpred);
}
if (isa<FPMathOperator>(Sel))
Sel = cast<SelectInst>(setFPAttrs(Sel, nullptr /* MDNode* */, FMF));
setFPAttrs(Sel, nullptr /* MDNode* */, FMF);
return Insert(Sel, Name);
}

Expand Down

0 comments on commit 4a92230

Please sign in to comment.