]> granicus.if.org Git - llvm/commit
[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)
commitb3518390c199198cece243575d6ea3dca01090cf
tree506e6ae27597596cc2e7fd1a530f0f686ea52364
parent41042eb4562bfe52e7904d30c893de3461620cff
[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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301329 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Analysis/InstructionSimplify.cpp
test/Transforms/InstSimplify/AndOrXor.ll