[PATCH] D112108: [InstCombine] Fold `(a & ~b) & ~c` to `a & ~(b | c)`

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 21 12:14:22 PDT 2021


spatel added a comment.

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).


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