[all-commits] [llvm/llvm-project] e6f694: [InstCombine] (~a & b & c) | ~(a | b) -> (c | ~b) ...

Stanislav Mekhanoshin via All-commits all-commits at lists.llvm.org
Wed Dec 15 09:37:15 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: e6f694229696e939f366ab98eb86cddb5038cd8c
      https://github.com/llvm/llvm-project/commit/e6f694229696e939f366ab98eb86cddb5038cd8c
  Author: Stanislav Mekhanoshin <Stanislav.Mekhanoshin at amd.com>
  Date:   2021-12-15 (Wed, 15 Dec 2021)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
    M llvm/test/Transforms/InstCombine/and-xor-or.ll

  Log Message:
  -----------
  [InstCombine] (~a & b & c) | ~(a | b) -> (c | ~b) & ~a

Transform
```
(~a & b & c) | ~(a | b) -> (c | ~b) & ~a
```
and swapped case
```
(~a | b | c) & ~(a & b) -> (c & ~b) | ~a
```

```
----------------------------------------
define i4 @src(i4 %a, i4 %b, i4 %c) {
%0:
  %or1 = or i4 %b, %a
  %not1 = xor i4 %or1, 15
  %not2 = xor i4 %a, 15
  %and1 = and i4 %b, %not2
  %and2 = and i4 %and1, %c
  %or2 = or i4 %and2, %not1
  ret i4 %or2
}
=>
define i4 @tgt(i4 %a, i4 %b, i4 %c) {
%0:
  %notb = xor i4 %b, 15
  %or = or i4 %notb, %c
  %nota = xor i4 %a, 15
  %and = and i4 %or, %nota
  ret i4 %and
}
Transformation seems to be correct!
```

```
----------------------------------------
define i4 @src(i4 %a, i4 %b, i4 %c) {
%0:
  %and1 = and i4 %b, %a
  %not1 = xor i4 %and1, 15
  %not2 = xor i4 %a, 15
  %or1 = or i4 %b, %not2
  %or2 = or i4 %or1, %c
  %and2 = and i4 %or2, %not1
  ret i4 %and2
}
=>
define i4 @tgt(i4 %a, i4 %b, i4 %c) {
%0:
  %notb = xor i4 %b, 15
  %and = and i4 %notb, %c
  %nota = xor i4 %a, 15
  %or = or i4 %and, %nota
  ret i4 %or
}
Transformation seems to be correct!
```

Differential Revision: https://reviews.llvm.org/D113037




More information about the All-commits mailing list