[InstSimplify] Handle (~A & ~B) | (~A ^ B) -> ~A ^ B
authorCraig Topper <craig.topper@gmail.com>
Tue, 25 Apr 2017 17:01:32 +0000 (17:01 +0000)
committerCraig Topper <craig.topper@gmail.com>
Tue, 25 Apr 2017 17:01:32 +0000 (17:01 +0000)
commit0b650d35698d7a80352f3f4a67289b8b47df4726
treeb456b2b1ec7a19b3de4feb063bd72c38977be156
parent3c0ede7f7aa201a1f4910f097682a796451d344b
[InstSimplify] Handle (~A & ~B) | (~A ^ B) -> ~A ^ B

The code Sanjay Patel moved over from InstCombine doesn't work properly if the 'and' has both inputs as nots because we used a commuted op matcher on the 'and' first. But this will bind to the first 'not' on 'and' when there could be two 'not's. InstCombine could rely on DeMorgan to ensure the 'and' wouldn't have two 'not's eventually, but InstSimplify can't rely on that.

This patch matches the xor first then checks for the ands and allows a not of either operand of the xor.

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

llvm-svn: 301329
llvm/lib/Analysis/InstructionSimplify.cpp
llvm/test/Transforms/InstSimplify/AndOrXor.ll