[llvm] r339349 - [InstCombine] reduce code duplication; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 9 08:07:13 PDT 2018
Author: spatel
Date: Thu Aug 9 08:07:13 2018
New Revision: 339349
URL: http://llvm.org/viewvc/llvm-project?rev=339349&view=rev
Log:
[InstCombine] reduce code duplication; NFC
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp?rev=339349&r1=339348&r2=339349&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp Thu Aug 9 08:07:13 2018
@@ -1892,17 +1892,15 @@ Instruction *InstCombiner::visitFSub(Bin
// 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);
More information about the llvm-commits
mailing list