[LLVMdev] The nsw story

David A. Greene greened at obbligato.org
Tue Dec 6 09:10:58 PST 2011

Dan Gohman <gohman 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.

And thus they are undef because the low 32 bits were/are undef.

> And the low 32 bits in this new value also fluctuate, and the
> high 31 bits in this value fluctuate with them in concert with
> bit 31 of the new value.

That's just ridiculous.  Undef is undef.  We don't know anything special
about it.

> FWIW, you can also get non-bitwise fluctuation, such as (undef*3), which
> is a value which fluctuates around multiples of 3. Or (undef*3)/5+1,
> which fluctuates around, well, any value which could be computed by
> that expression. You can build arbitrarily complex expression trees
> around undef, and everything fluctuates according to the constraints of
> operands and opcodes. It's quite magical.

This is silly.  We can't count on undef having any special properties at
all.  If we do, IMHO it's a bug.


More information about the llvm-dev mailing list