diff options
author | Sanjay Patel <spatel@rotateright.com> | 2018-08-08 16:04:48 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2018-08-08 16:04:48 +0000 |
commit | 2054dd79c200f2a3b7d6e770dd92a1908fbc25dc (patch) | |
tree | 660a9051e1b6f2090d0e45020300294b35034709 /llvm/lib/Transforms | |
parent | 58df0e4d2cc7269d4cf54a5aa020dcd66ac0cf34 (diff) | |
download | bcm5719-llvm-2054dd79c200f2a3b7d6e770dd92a1908fbc25dc.tar.gz bcm5719-llvm-2054dd79c200f2a3b7d6e770dd92a1908fbc25dc.zip |
[InstCombine] fold fsub+fsub with common operand
This is a sibling to the simplify from:
rL339171
llvm-svn: 339266
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp index 052cb4ab675..f3fe09f1cb0 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp @@ -1907,6 +1907,14 @@ Instruction *InstCombiner::visitFSub(BinaryOperator &I) { return replaceInstUsesWith(I, V); if (I.hasAllowReassoc() && I.hasNoSignedZeros()) { + // (Y - X) - Y --> -X + if (match(Op0, m_FSub(m_Specific(Op1), m_Value(X)))) + return BinaryOperator::CreateFNegFMF(X, &I); + + // TODO: This performs reassociative folds for FP ops. Some fraction of the + // functionality has been subsumed by simple pattern matching here and in + // InstSimplify. We should let a dedicated reassociation pass handle more + // complex pattern matching and remove this from InstCombine. if (Value *V = FAddCombine(Builder).simplify(&I)) return replaceInstUsesWith(I, V); } |