[llvm-dev] Killing undef and spreading poison

Sanjoy Das via llvm-dev llvm-dev at lists.llvm.org
Tue Oct 18 12:44:38 PDT 2016


Hi,

Nuno Lopes wrote:

>> Okay; so the problem is that an instruction that is value-equivalent
>> to a poison value is not itself necessarily poison?
>
> Right.
> I think there were other examples, but I don't have them here handy. But
> at least this one is very problematic for GVN.

Another example is this:

void f(int k) {
   if (k != 0) {
     for (< finite loop >) {
       if (always_false_at_runtime) {
         print(1 / k);
       }
     }
   }
}

We'd like to hoist the `1 / k` computation to the preheader.  However, 
we can't do that today if `k` is undef, and we've defined branching on 
undef to be a non-deterministic choice.

I have some more details at: 
http://www.playingwithpointers.com/problem-with-undef.html

-- Sanjoy


More information about the llvm-dev mailing list