[LLVMdev] The nsw story
David A. Greene
greened at obbligato.org
Tue Dec 6 09:18:09 PST 2011
Chris Lattner <clattner at apple.com> writes:
>> No; sext i32 undef to i64 returns an extraordinary thing. It's a
>> 64-bit value where the low 32 bits are undef, and the high
>> 32 bits are sign extension from whatever bit 31 happened to be.
>
> More precisely, the high 33 bits are known to be the same.
I think that's a very risky assumption. The name "undef" does not
convey that at all.
>> operands and opcodes. It's quite magical.
>
> It's actually not that magical. It's also essential that we have this
> behavior, otherwise normal bitfield code has "undefined" behavior and
> is misoptimized. This is why the result of "undef & 1" is known to
> have high bits zero.
Well sure, because we know (x & 1) has the high bits set to zero for any
value of x. In the sext case, we know nothing about the high bits
because we don't know what bit 32 was/is.
Yes, we know the high bits are the same but it's surprising to me that
this would be represented as "undef." "undef" to me means I can assume
any value at all, not restricted to "all the bits are the same."
-Dave
More information about the llvm-dev
mailing list