[llvm-commits] SETCC InstructionCombining.cpp [#2/3]

Reid Spencer rspencer at reidspencer.com
Fri Dec 22 15:08:52 PST 2006


On Fri, 2006-12-22 at 12:08 -0800, Chris Lattner wrote:

> 
> +/// Four bits are used to represent the condition, as follows:
> +///   0  A > B
> +///   1  A == B
> +///   2  A < B
> +///   3  A and B are signed
> +/// 
> +/// S<=>   Definition              S<=>   Definition
> +/// 0000   Always false            1000   Alwasy false
> +/// 0001   A u> B                  1001   A s> B
> +/// 0010   A == B                  1010   A == B
> +/// 0011   A u>= B                 1011   A s>= B
> +/// 0100   A u< B                  1100   A s< B
> +/// 0101   A != B                  1101   A != B
> +/// 0110   A u<= B                 1110   A s<= B
> +/// 0111   Always true             1111   Always true
> +///  
> +static unsigned getICmpCode(const ICmpInst *ICI) {
> 
> 
> This table (and it's use) is not correct.  It will miscompile:
> 
> 
> (a <u b) | (a <s b)
> 
> 
> You really want separate bits for s<, s>, u<, u>.  In this case, you'd
> detect that the merged comparison can't be done with a single compare,
> so you give up.

I don't understand. There are separate bits for each of those.

s< = 1100
s> = 1001
u< = 0100
u> = 0001


> 




More information about the llvm-commits mailing list