[LLVMdev] The nsw story

David A. Greene greened at obbligato.org
Thu Dec 1 09:44:26 PST 2011


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."  If the latter, there
is no problem with undef "changing values" as a result of various
operations, including sign extension.

> Therefore, if signed add overflow returns undef, promoting such 32-bit variables to
> 64-bit variables is not a behavior-preserving transformation.

Sure it is, if undef is allowed to "float freely" and change its value
on a whim.  The behavior is, "this could be anything at any time."

If I'm understanding you correctly.

                                      -Dave



More information about the llvm-dev mailing list