[PATCH] D61307: [InstCombine] Add new combine to sub folding
Chris Dawson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 30 07:47:55 PDT 2019
cdawson added inline comments.
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp:1535-1536
+ // (Y | X) - Y --> (Y | X) ^ Y
+ if (match(Op0, m_OneUse(m_c_Or(m_Value(X), m_Specific(Op1)))))
+ return BinaryOperator::CreateXor(Builder.CreateOr(X, Op1), Op1);
+
----------------
lebedev.ri wrote:
> I do not understand. You don't change the inner pattern at all.
> Just do:
> ```
> if (match(Op0, m_c_Or(m_Specific(Op1), m_Value())))
> return BinaryOperator::CreateXor(Op0, Op1);
> ```
I totally agree with the change to the return statement and the m_c_Or check.
One point I'd like clarification on is the removal of the m_OneUse. I was including that since the transformation is to facilitate a further (X | Y) ^ Y --> X & ~Y which will only happen if there are no extra uses of (X | Y). If you think we should always transform (X | Y) - Y --> (X | Y) ^ Y I'm happy to remove the m_OneUse.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D61307/new/
https://reviews.llvm.org/D61307
More information about the llvm-commits
mailing list