[LLVMdev] Proposal to Remove Poison

Nuno Lopes nuno.lopes at ist.utl.pt
Tue Feb 17 10:35:28 PST 2015


>>  Sanjoy proposed in another email to make undef an instruction. That would actually solve this problem. SROA could replace the load with an undef instruction, forcing %and to be true. Undef instructions could be determinized to 0 in codegen (if not removed beforehand).
> 
> Undef-as-an-instruction has a problem when combined with "loads from uninitialized memory are undef".  If by "loads from uninitialized memory are undef" we mean the old "undef" then we have the same problem of "xor %x, %x" not always being zero.  > And if by "loads from uninitialized memory are undef" we mean "the load is equivalent to an gen_undef instruction" then we cannot duplicate loads unless we know that the load is from initialized memory since
> 
> %x = load P
> %y = xor %x, %x
> 
> is not the same as
> 
> %x0 = load P
> %x1 = load P
> %y = xor %x0, %x1
> 
> for an uninitialized *P

Aah, right. This stuff is mind blowing :)
Nuno

> -- Sanjoy
> 
>>
>> The downsize of having just one type of undef is that then all undefs are the same in the following sense:
>> %mem = alloca
>> %load = load %mem
>> %cmp = icmp slt %load, INT_MIN
>>
>> With current LLVM, %cmp will always be false. With your proposal, %cmp will be undef, and therefore potentially true, which is strange.
>>
>>
>> Nuno





More information about the llvm-dev mailing list