[InstCombine] add folds for icmp with xor mask constant
authorSanjay Patel <spatel@rotateright.com>
Tue, 11 Sep 2018 22:00:15 +0000 (22:00 +0000)
committerSanjay Patel <spatel@rotateright.com>
Tue, 11 Sep 2018 22:00:15 +0000 (22:00 +0000)
commit26725bdc508f0c011e39f7ef0125e961d2ad76ed
treea605d8148f3cf67598cb64ec4f2e65009d6667ef
parentc72a7259bee5779f8627bbf464f53c0c993274e0
[InstCombine] add folds for icmp with xor mask constant

These are the folds in Alive;
Name: xor_ult
Pre: isPowerOf2(-C1)
%xor = xor i8 %x, C1
%r = icmp ult i8 %xor, C1
=>
%r = icmp ugt i8 %x, ~C1

Name: xor_ugt
Pre: isPowerOf2(C1+1)
%xor = xor i8 %x, C1
%r = icmp ugt i8 %xor, C1
=>
%r = icmp ugt i8 %x, C1

https://rise4fun.com/Alive/Vty

The ugt case in its simplest form was already handled by DemandedBits,
but that's not ideal as shown in the multi-use test.

I'm not sure if these are all of the symmetrical folds, but I adjusted
the existing code for one of the folds to try to show the similarities.

There's no obvious connection, but this is another preliminary step
for PR14613...
https://bugs.llvm.org/show_bug.cgi?id=14613

llvm-svn: 341997
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
llvm/test/Transforms/InstCombine/icmp.ll