diff options
author | Sanjay Patel <spatel@rotateright.com> | 2018-08-09 15:07:13 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2018-08-09 15:07:13 +0000 |
commit | ebec4204da174dfd631e19ab19d8e071f4731818 (patch) | |
tree | fdff5a80178b0a3fb099e5f4ef06e95fbd690da9 /llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp | |
parent | dffc1911e2197f18a44995f46b7e45eeb37a0c63 (diff) | |
download | bcm5719-llvm-ebec4204da174dfd631e19ab19d8e071f4731818.tar.gz bcm5719-llvm-ebec4204da174dfd631e19ab19d8e071f4731818.zip |
[InstCombine] reduce code duplication; NFC
llvm-svn: 339349
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp index 8b355dcd1b2..16e3d742ce0 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp @@ -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); - } + 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); + // 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); - } + if (match(Op1, m_OneUse(m_FPExt(m_FNeg(m_Value(Y)))))) + return BinaryOperator::CreateFAddFMF(Op0, Builder.CreateFPExt(Y, Ty), &I); - // Handle specials cases for FSub with selects feeding the operation + // Handle special cases for FSub with selects feeding the operation if (Value *V = SimplifySelectsFeedingBinaryOp(I, Op0, Op1)) return replaceInstUsesWith(I, V); |