[PATCH] D145157: [InstCombine] Implement "A & (~A | B) --> A & B" for boolean vectors.

Paul Walker via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 2 09:52:03 PST 2023


paulwalker-arm added inline comments.


================
Comment at: llvm/test/Transforms/InstCombine/logical-select.ll:1132
+  %not = xor <2 x i1> %a, <i1 true, i1 true>
+  %or = or <2 x i1> %b, %not
+  %and = select <2 x i1> %a, <2 x i1> %or, <2 x i1> zeroinitializer
----------------
spatel wrote:
> This isn't doing what we wanted - the `not` will get commuted to operand 0.
> To keep it as operand 1, we need something like this:
> 
> 
> ```
> declare i1 @gen()
> 
> define i1 @and_commute1(i1 %a) {
>   %b = call i1 @gen()
>   %nota = xor i1 %a, 1
>   %or = or i1 %b, %nota
>   %and = select i1 %a, i1 %or, i1 0
>   ret i1 %and
> }
> ```
> 
> We also need matching and tests for patterns where the "or-not" is the condition value of the select?
The "or-not is the condition" case already works, whereby it's converted to an "and" (See https://alive2.llvm.org/ce/z/bxZ37W). I'm not sure why that case doesn't have the same poison issues that my case has.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145157/new/

https://reviews.llvm.org/D145157



More information about the llvm-commits mailing list