[PATCH] D158983: [InstCombine] Fold two select patterns into or-and

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 28 07:54:39 PDT 2023


nikic added inline comments.


================
Comment at: llvm/test/Transforms/InstCombine/select-and-or.ll:682
+  %notc = xor <2 x i1> %c, <i1 true, i1 true>
+  %cond = or <2 x i1> %notc, %a
+  %r = select <2 x i1> %cond, <2 x i1> %a, <2 x i1> %b
----------------
Swap the operand of the `or` here to cover the commuted case.


================
Comment at: llvm/test/Transforms/InstCombine/select-and-or.ll:711
+
+define i1 @neg_or_and1(i1 %a, i1 %b, i1 %c, i1 %d) {
+; CHECK-LABEL: @neg_or_and1(
----------------
nikic wrote:
> Something is wrong with these negative tests. You have an unused variable `%a`.
We do still need negative tests where the not operand is not the same as the other select operand. The previous test had the right idea, it just didn't use the correct variables. It should be something like this:
```
define i1 @or_and1_wrong_operand(i1 %a, i1 %b, i1 %c, i1 %c) {
  %notb = xor i1 %b, true
  %cond = and i1 %notb, %c
  %r = select i1 %cond, i1 %a, i1 %d
  ret i1 %r
}
```
And similar for the other case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158983



More information about the llvm-commits mailing list