mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-02 00:16:25 +00:00
[InstCombine] reduce code duplication; NFC
llvm-svn: 339349
This commit is contained in:
parent
a966616fae
commit
fdc2e3fdbb
@ -1892,17 +1892,15 @@ Instruction *InstCombiner::visitFSub(BinaryOperator &I) {
|
||||
|
||||
// Similar to above, but look through a cast of the negated value:
|
||||
// X - (fptrunc(-Y)) --> X + fptrunc(Y)
|
||||
if (match(Op1, m_OneUse(m_FPTrunc(m_FNeg(m_Value(Y)))))) {
|
||||
Value *TruncY = Builder.CreateFPTrunc(Y, I.getType());
|
||||
return BinaryOperator::CreateFAddFMF(Op0, TruncY, &I);
|
||||
}
|
||||
// X - (fpext(-Y)) --> X + fpext(Y)
|
||||
if (match(Op1, m_OneUse(m_FPExt(m_FNeg(m_Value(Y)))))) {
|
||||
Value *ExtY = Builder.CreateFPExt(Y, I.getType());
|
||||
return BinaryOperator::CreateFAddFMF(Op0, ExtY, &I);
|
||||
}
|
||||
Type *Ty = I.getType();
|
||||
if (match(Op1, m_OneUse(m_FPTrunc(m_FNeg(m_Value(Y))))))
|
||||
return BinaryOperator::CreateFAddFMF(Op0, Builder.CreateFPTrunc(Y, Ty), &I);
|
||||
|
||||
// Handle specials cases for FSub with selects feeding the operation
|
||||
// X - (fpext(-Y)) --> X + fpext(Y)
|
||||
if (match(Op1, m_OneUse(m_FPExt(m_FNeg(m_Value(Y))))))
|
||||
return BinaryOperator::CreateFAddFMF(Op0, Builder.CreateFPExt(Y, Ty), &I);
|
||||
|
||||
// Handle special cases for FSub with selects feeding the operation
|
||||
if (Value *V = SimplifySelectsFeedingBinaryOp(I, Op0, Op1))
|
||||
return replaceInstUsesWith(I, V);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user