[PATCH] D67155: [InstCombine] Fold sub (and A, B) (or A, B)) to not (xor A, B)

Dávid Bolvanský via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 4 05:23:39 PDT 2019


xbolva00 created this revision.
xbolva00 added a reviewer: lebedev.ri.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

  Name: sub(and(x, y), or(x, y)) -> neg(xor(x, y))
  %or = or i32 %y, %x
  %and = and i32 %x, %y
  %sub = sub i32 %and, %or
    =>
  %sub1 = xor i32 %x, %y
  %sub = sub i32 0, %sub1
  
  Optimization: sub(and(x, y), or(x, y)) -> neg(xor(x, y))
  Done: 1
  Optimization is correct!

https://rise4fun.com/Alive/VI6

Found by @lebedev.ri. Also author of the proof.


Repository:
  rL LLVM

https://reviews.llvm.org/D67155

Files:
  lib/Transforms/InstCombine/InstCombineAddSub.cpp
  test/Transforms/InstCombine/sub-and-or-not-xor.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67155.218655.patch
Type: text/x-patch
Size: 4155 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190904/2ffe8f6e/attachment.bin>


More information about the llvm-commits mailing list