HomePhabricator

[InstCombine] Fold sub (and A, B) (or A, B)) to neg (xor A, B)

Description

[InstCombine] Fold sub (and A, B) (or A, B)) to neg (xor A, B)

Summary:

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.

Reviewers: lebedev.ri, spatel

Reviewed By: lebedev.ri

Subscribers: llvm-commits, lebedev.ri

Tags: #llvm

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

Details

Committed
xbolva00Wed, Sep 4, 10:30 AM
Reviewer
lebedev.ri
Differential Revision
D67155: [InstCombine] Fold sub (and A, B) (or A, B)) to neg (xor A, B)
Parents
rL370933: [Instruction] Add hasMetadata(Kind) helper [NFC]
Branches
Unknown
Tags
Unknown