[llvm-commits] SETCC InstructionCombining.cpp [#2/3]
Chris Lattner
clattner at apple.com
Fri Dec 22 17:27:00 PST 2006
On Dec 22, 2006, at 3:08 PM, Reid Spencer wrote:
> 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
If you or together s< and u< you get 1100, which is thought to be
s<. This is not valid.
You want
== -> 00001
s< -> 00010
s> -> 00100
u< -> 01000
u> -> 10000
or something
-Chris
More information about the llvm-commits
mailing list