[LLVMdev] RFC: Proposal to Remove Poison

Sanjoy Das sanjoy at playingwithpointers.com
Sun Feb 8 15:10:18 PST 2015


> If we instead ran SROA over @g, we would be left with:
>   %cmp0 = icmp eq i1 undef, false
>   %cmp1 = icmp eq i1 undef, true
>   %and = xor i1 %cmp0, %cmp1

I think it has to be that way, since otherwise the two programs:

 %x = load %M
 %y = load %M
 use(%x, %y)

and

 %x = load %M
 use(%x, %x)

would not be equivalent and we would not be able to do load commoning
(I'm somewhat speculating here -- I'm not actually sure if the two
programs above are equivalent).  And those load instructions are
independently undef.  In other words, the "problem" here is that the
two programs above are supposed to be equivalent *and* that a load
from an uninitialized location is undef.

I agree with Hal that the right way to assign semantics to undef is
that say that it is some N bit value at each *use*; and the N bit
value undef pretends to be at each use may be a different one.  I
think this also justifies existence of undef -- if uninitialized loads
were supposed to be just some value consistently, then you could get
the same semantics by saying that uninitialized locations contain
"some arbitrary N bit value".  Stating that loads from uninitialized
values are undef is strictly stronger, as your example shows.

-- Sanjoy

>
> Now that %cmp0 and %cmp1 have different undef values, %and is now undef.
> This result is sufficient to say that the contents of %mem are neither true
> nor false!
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>



More information about the llvm-dev mailing list