[PATCH] D113037: [InstCombine] (~a & b & c) | ~(a | b) -> (c | ~b) & ~a

Stanislav Mekhanoshin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 2 11:23:52 PDT 2021


rampitec created this revision.
rampitec added a reviewer: spatel.
Herald added a subscriber: hiraditya.
rampitec requested review of this revision.
Herald added a project: LLVM.

  ----------------------------------------
  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!


https://reviews.llvm.org/D113037

Files:
  llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
  llvm/test/Transforms/InstCombine/and-xor-or.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113037.384172.patch
Type: text/x-patch
Size: 11251 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211102/ef78cbed/attachment-0001.bin>


More information about the llvm-commits mailing list