[PATCH] D112108: [InstCombine] Fold `(a & ~b) & ~c` to `a & ~(b | c)`
Stanislav Mekhanoshin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 21 12:20:47 PDT 2021
rampitec added a comment.
In D112108#3078966 <https://reviews.llvm.org/D112108#3078966>, @spatel wrote:
> In D112108#3078420 <https://reviews.llvm.org/D112108#3078420>, @rampitec wrote:
>
>> (c & ~(a | b)) | (b & ~(a | c)) --> ~a & (b ^ c)
>>
>> We currently cannot simplify it.
>>
>> define i32 @or_not_and(i32 %a, i32 %b, i32 %c) {
>> %or1 = or i32 %a, %b
>> %not1 = xor i32 %or1, -1
>> %and1 = and i32 %not1, %c
>> %or2 = or i32 %a, %c
>> %not2 = xor i32 %or2, -1
>> %and2 = and i32 %not2, %b
>> %or3 = or i32 %and1, %and2
>> ret i32 %or3
>> }
>
> Hmm...so that's 2 of the patterns in this patch glued together. I don't see an intermediate fold that we can use to reduce it. Either you have to hard-code a big pattern match or add a generalized boolean logic solver (as its own pass).
Having a separate boolean logic solver might be a good idea in a long run. I.e. collect operands unused ouside of a dag solved, build truth table, generate a minimal expression. But that probably needs much more thought than this initial idea.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D112108/new/
https://reviews.llvm.org/D112108
More information about the llvm-commits
mailing list