[PATCH] D114339: [InstCombine] simplify (~A | B) ^ A --> ~( A & B)
Mehrnoosh Heidarpour via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Nov 27 09:43:11 PST 2021
MehrHeidar added inline comments.
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:3657-3658
+ // A ^ (~A | B) --> ~(A & B)
+ if (match(Op1, m_OneUse(m_c_Or(m_Not(m_Value(A)), m_Value(B)))) &&
+ match(Op0, m_Deferred(A)))
+ return BinaryOperator::CreateNot(Builder.CreateAnd(A, B));
----------------
spatel wrote:
> Is this logically different than the m_Specific(Op0) code pattern that I suggested?
> Unless I'm missing something, you don't need to use m_Deferred either way. In this code, the clause before `&&` must run and capture 'A' before it is matched as Op0.
Sorry for delay on following this issue.
> Is this logically different than the m_Specific(Op0) code pattern that I suggested?
> Unless I'm missing something, you don't need to use m_Deferred either way. In this code, the clause before `&&` must run and capture 'A' before it is matched as Op0.
Oh, I see. I think I misunderstood your previous comment then. I tried to avoid any use of `Op0/Op1` in any of the `m_Specific/m_Value/m_Deferred`, so I wrote the code in that way in the previous commit. I did replace the code as your suggestion.
Thanks.
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:3657-3658
+ // A ^ (~A | B) --> ~(A & B)
+ if (match(Op1, m_OneUse(m_c_Or(m_Not(m_Value(A)), m_Value(B)))) &&
+ match(Op0, m_Deferred(A)))
+ return BinaryOperator::CreateNot(Builder.CreateAnd(A, B));
----------------
MehrHeidar wrote:
> spatel wrote:
> > Is this logically different than the m_Specific(Op0) code pattern that I suggested?
> > Unless I'm missing something, you don't need to use m_Deferred either way. In this code, the clause before `&&` must run and capture 'A' before it is matched as Op0.
> Sorry for delay on following this issue.
>
> > Is this logically different than the m_Specific(Op0) code pattern that I suggested?
> > Unless I'm missing something, you don't need to use m_Deferred either way. In this code, the clause before `&&` must run and capture 'A' before it is matched as Op0.
> Oh, I see. I think I misunderstood your previous comment then. I tried to avoid any use of `Op0/Op1` in any of the `m_Specific/m_Value/m_Deferred`, so I wrote the code in that way in the previous commit. I did replace the code as your suggestion.
>
> Thanks.
> Is this logically different than the m_Specific(Op0) code pattern that I suggested?
> Unless I'm missing something, you don't need to use m_Deferred either way. In this code, the clause before `&&` must run and capture 'A' before it is matched as Op0.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D114339/new/
https://reviews.llvm.org/D114339
More information about the llvm-commits
mailing list