[PATCH] InstCombineCompare with constant return false if we know it is never going to be equal

Duncan Sands duncan.sands at gmail.com
Fri May 30 06:43:58 PDT 2014


Hi Suyog,

On 30/05/14 15:01, suyog wrote:
> Gentle Ping !!
>
> http://reviews.llvm.org/D3868

I only glanced at this but it seems much less general than it could be.

Suppose you are analysing icmp eq A, B

Let A_Known_Zero and A_Known_One give the bits of A that are known to be 
zero/one.  Likewise B_Known_Zero and B_Known_One for B.

If a bit is known to be zero for A and known to be one for B then A and B cannot 
be equal.  Likewise, if a bit if known to be one for A and known to be zero for 
B then A != B.

Thus, if A_Known_Zero & B_Known_One != 0 then A != B.  Same if A_Known_One & 
B_Known_Zero != 0.

I think this covers your case and many more.

Ciao, Duncan.




More information about the llvm-commits mailing list