Skip to content

Commit 3f50904

Browse files
committed
InstCombine: Set operands instead of creating new call
llvm-svn: 291612
1 parent fdb78f8 commit 3f50904

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,21 +1599,17 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
15991599
// fma fneg(x), fneg(y), z -> fma x, y, z
16001600
if (match(Src0, m_FNeg(m_Value(LHS))) &&
16011601
match(Src1, m_FNeg(m_Value(RHS)))) {
1602-
CallInst *NewCall = Builder->CreateCall(II->getCalledFunction(),
1603-
{LHS, RHS, II->getArgOperand(2)});
1604-
NewCall->takeName(II);
1605-
NewCall->copyFastMathFlags(II);
1606-
return replaceInstUsesWith(*II, NewCall);
1602+
II->setArgOperand(0, LHS);
1603+
II->setArgOperand(1, RHS);
1604+
return II;
16071605
}
16081606

16091607
// fma fabs(x), fabs(x), z -> fma x, x, z
16101608
if (match(Src0, m_Intrinsic<Intrinsic::fabs>(m_Value(LHS))) &&
16111609
match(Src1, m_Intrinsic<Intrinsic::fabs>(m_Value(RHS))) && LHS == RHS) {
1612-
CallInst *NewCall = Builder->CreateCall(II->getCalledFunction(),
1613-
{LHS, LHS, II->getArgOperand(2)});
1614-
NewCall->takeName(II);
1615-
NewCall->copyFastMathFlags(II);
1616-
return replaceInstUsesWith(*II, NewCall);
1610+
II->setArgOperand(0, LHS);
1611+
II->setArgOperand(1, RHS);
1612+
return II;
16171613
}
16181614

16191615
// fma x, 1, z -> fadd x, z

0 commit comments

Comments
 (0)