[LLVMdev] RFC: Proposal for Poison Semantics

Sanjoy Das sanjoy at playingwithpointers.com
Sun Feb 1 12:58:29 PST 2015


> That being said, we don't perform this transform today and I don't see why
> we would want to.  I'd happily give up this flexibility if it meant that we
> could keep everything else.

I was under the impression that "zext(add nuw X Y) == add nuw zext(X),
zext(Y)" is the very definition of nuw (i.e. all properties of nuw/nsw
are supposed to
follow from that).  If we wish to go ahead without that equivalence,
then I agree we probably don't need the higher bits to be poison when
zexting poison.

IOW, the higher bits of the zext of poison needs to be poison because
we want the "zext(add nuw X Y) == add nuw zext(X), zext(Y)" transform
to not change the meaning of a program.  Hence any program whose
meaning would change because of this transform needs to have UB to
start with.

This is also the root of the issue Chandler pointed out -- "(zext X)"
and "(and 0x7f (zext X))" are _not_ the same value because a
non-trivial use of the first value induces a dependence on the bits
that may change with the "zext(add nuw X Y) == add nuw zext(X),
zext(Y)" transform while a non-trivial use of the second value does
not.

-- Sanjoy



More information about the llvm-dev mailing list