[LLVMdev] The nsw story

Eli Friedman eli.friedman at gmail.com
Thu Dec 1 10:19:36 PST 2011


On Thu, Dec 1, 2011 at 9:44 AM, David A. Greene <greened at obbligato.org> wrote:
> Dan Gohman <gohman at apple.com> writes:
>
>> In a world where signed add overflow returns undef, c could be any of
>>   0x0000000000000000
>>   0x0000000000000001
>>   0x0000000000000002
>>   ...
>>   0x000000007fffffff
>> or
>>   0xffffffff80000000
>>   0xffffffff80000001
>>   0xffffffff80000002
>>   ...
>>   0xffffffffffffffff
>> however it can't ever be 0x0000000080000000, because there's no 32-bit value
>> the undef could take which sign-extends into that 64-bit value.
>
> Is undef considered to be "one true value" which is just unknown?  I
> always considered it to be "any possible value."

The current LLVM IR definition of undef is essentially "each time
undef is evaluated, it evaluates to an arbitrary value, but it must
evaluate to some specific value".  SimplifyDemandedBits is an example
of a transformation which uses undef in a way that would be incorrect
under a model where undef is like the current trap value; take a look
at r133022 for a case where this matters.

-Eli




More information about the llvm-dev mailing list