llvm-project/llvm/lib/Transforms/InstCombine
Stanislav Mekhanoshin c407769f5e [InstCombine] (~(a | b) & c) | ~(c | (a ^ b)) -> ~((a | b) & (c | (b ^ a)))
Transform
```
(~(a | b) & c) | ~(c | (a ^ b)) -> ~((a | b) & (c | (b ^ a)))
```
And swapped case:
```
(a | ~(b & c)) & ~(a & (b ^ c)) --> ~(a | b) | (a ^ b ^ c)
```

```
----------------------------------------
define i3 @src(i3 %a, i3 %b, i3 %c) {
%0:
  %or1 = or i3 %b, %c
  %not1 = xor i3 %or1, 7
  %and1 = and i3 %a, %not1
  %xor1 = xor i3 %b, %c
  %or2 = or i3 %xor1, %a
  %not2 = xor i3 %or2, 7
  %or3 = or i3 %and1, %not2
  ret i3 %or3
}
=>
define i3 @tgt(i3 %a, i3 %b, i3 %c) {
%0:
  %obc = or i3 %b, %c
  %xbc = xor i3 %b, %c
  %o = or i3 %a, %xbc
  %and = and i3 %obc, %o
  %r = xor i3 %and, 7
  ret i3 %r
}
Transformation seems to be correct!
```
```
----------------------------------------
define i4 @src(i4 %a, i4 %b, i4 %c) {
%0:
  %and1 = and i4 %b, %c
  %not1 = xor i4 %and1, 15
  %or1 = or i4 %not1, %a
  %xor1 = xor i4 %b, %c
  %and2 = and i4 %xor1, %a
  %not2 = xor i4 %and2, 15
  %and3 = and i4 %or1, %not2
  ret i4 %and3
}
=>
define i4 @tgt(i4 %a, i4 %b, i4 %c) {
%0:
  %xor1 = xor i4 %b, %c
  %xor2 = xor i4 %xor1, %a
  %or1 = or i4 %a, %b
  %not1 = xor i4 %or1, 15
  %or2 = or i4 %xor2, %not1
  ret i4 %or2
}
Transformation seems to be correct!
```

Differential Revision: https://reviews.llvm.org/D112955
2021-11-22 10:49:21 -08:00
..
CMakeLists.txt llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
InstCombineAddSub.cpp [InstCombine] fix code comment to match code; NFC 2021-11-09 14:27:29 -05:00
InstCombineAndOrXor.cpp [InstCombine] (~(a | b) & c) | ~(c | (a ^ b)) -> ~((a | b) & (c | (b ^ a))) 2021-11-22 10:49:21 -08:00
InstCombineAtomicRMW.cpp Add missing namespace closure comments. NFCI. 2020-09-23 16:19:25 +01:00
InstCombineCalls.cpp [InstCombine] Extend stacksave/restore elimination 2021-11-10 10:41:58 +02:00
InstCombineCasts.cpp [Transforms] Use {DenseSet,SetVector,SmallPtrSet}::contains (NFC) 2021-10-31 07:57:32 -07:00
InstCombineCompares.cpp [InstCombine] canonicalize icmp with trunc op into mask and cmp, part 2 2021-11-16 09:27:30 -05:00
InstCombineInternal.h [InstCombine] add folds for binop with sexted bool and constant operands 2021-11-20 12:33:00 -05:00
InstCombineLoadStoreAlloca.cpp [CSSPGO] Unblock optimizations with pseudo probe instrumentation part 3. 2021-10-12 09:44:12 -07:00
InstCombineMulDivRem.cpp [InstCombine] propagate no-wrap flag through select-of-mul fold 2021-10-12 12:57:20 -04:00
InstCombineNegator.cpp [InstCombine] allow Negator to fold multi-use select with constant arms 2021-10-28 08:35:58 -04:00
InstCombinePHI.cpp [InstCombine] Fold phi ( inttoptr/ptrtoint x ) to phi (x) 2021-08-03 17:52:59 +05:30
InstCombineSelect.cpp [InstCombine] Canonicalize range test idiom 2021-11-08 21:15:46 +01:00
InstCombineShifts.cpp [InstCombine] Use SpecificBinaryOp_match in two more places 2021-11-17 01:16:06 -08:00
InstCombineSimplifyDemanded.cpp [APInt] Stop using soft-deprecated constructors and methods in llvm. NFC. 2021-10-04 08:57:44 +01:00
InstCombineVectorOps.cpp [InstCombine] Extend pattern to replace shuffle's insertelement operand 2021-11-03 09:43:04 +01:00
InstructionCombining.cpp [InstCombine] add folds for binop with sexted bool and constant operands 2021-11-20 12:33:00 -05:00