[LLVMdev] Restoring SSA form

Vikram S. Adve vadve at cs.uiuc.edu
Tue Nov 23 09:36:10 PST 2004


>
> Here's 'foo' is always called with positive value. However, the value 
> range
> assigned to 'i' variable can be only [-inf, +inf], because uses of 'i'
> outside of condition can get any value. So, I'd like to convert the 
> above to:
>
>    i = 0;
>    if (i > 0) {
>      i = change_value_range(i);
>      foo(i);
>    }

I don't know why you said that mem2reg is too specialized to work for 
your problem, but at least for the example you gave you can make it 
work.  If you converted the above code to the following:

	i = 0;
    	if (i > 0) {
      		tmp = i;
		i = change_value_range(tmp);
		tmp = i;
      		foo(tmp);
    	}

and then replace i with an alloca'd location, mem2reg should restore 
SSA just fine (the tmp is needed so that the alloca pointer is not 
passed to change_value_range() or foo())

--Vikram
http://www.cs.uiuc.edu/~vadve
http://llvm.cs.uiuc.edu/




More information about the llvm-dev mailing list