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

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 2 09:01:16 PST 2023


spatel 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
----------------
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?


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