[LLVMdev] RFC: Proposal for Poison Semantics

Sanjoy Das sanjoy at playingwithpointers.com
Thu Jan 29 11:29:16 PST 2015


> I've been discussing a model with David that might steer poison back towards
> something that simply supports algebraic simplification. If we have a math
> operation that cannot wrap, then it notionally produces as many bits of
> undef as the operation could possibly produce. For example, "add nsw i8" can
> produce an i9 undef, and "mul nsw i8" can produce an undefined 16 bit
> bitpattern. This is strong enough to do things like "a + 1 > a  -->  true",
> because on overflow of "a + 1" we can choose an poison value of "MAX_INT +
> 1", even though that is not a valid i8 bit pattern.
>
> So, a short version would be that poison is like undef, except you get to
> include the overflow bits of the computation in your undef value.

I  suspect it will be hard to justify reg2mem is meaning preserving in
this scheme.  But if this can be made to work, then I agree that this
is the right thing to do -- an i32 poison effectively has the
semantics of a wider type, and it makes sense to be explicit in that.

-- Sanjoy



More information about the llvm-dev mailing list