[tree-ssa]: Easy way to get default def of a variable?

Andrew MacLeod amacleod@redhat.com
Thu Jun 5 19:14:00 GMT 2003


> The code is a bit complicated, so i'll simplify it.
> Given:
> <BLOCK 0>
> 
> while (1)
> {
> 	<BLOCK 1>
> 	a_5 = PHI <a_4 (0) <<<<< The default def, a_7 (13)>
>         b_9 = a_5 + 3;
> 	... (More uses of a_5 + 3)
> 	<BLOCK 13>
> 	a_7 = 7;
> }
> 
> To do this optimally, we do four things:
> 
> 1. Insert a save at the end of the loop
> 2. Insert a save before the loop
> 3. Insert reloads in place of all the redundant expressions.
> 4. Insert a phi for the two saves we made.
> 
> So that the end code looks like:
> <BLOCK 0>
> pretmp_1 = a_4  + 3;
> while (1)
> {
> <BLOCK 1>
> 	pretmp_2 = PHI<pretmp_1 (0), pretmp_3 (13)>
> 	b_9 = pretmp_2;
> 	.... (uses of a_5 + 3 replaced with pretmp_2)
> 	<BLOCK 13>
> 	a_7 = 7;
> 	pretmp_3 = a_7 + 3;
> }
> 
> 
> When we go to generate the save at pretmp_1, the only thing we have to
> work with is the block we are in.  We don't have a handle to any "a_5 + 3"'s or
> anything, because none *exist at that point yet*.
> 

I still don't get it... maybe Im dense.  But looking for versions of a_
seems wrong. You know from the PHI what variables actually reach the
PHI.  The PHI doesnt even have to have an a_ in it, it could be

    a_5 = PHI <b_8(0), c_7(3)>

so a_5 + 3 is going to have nothing to do with a_*

or there could be an overlapping range of a_ reaching the PHI. Maybe
your PHI refers to a_4, but there could be a def of a_9 bewteen the PHI
and the def of a_4..  wouldn't you find the a_9?

SO I guess I dont understand what you are looking for...   I dont know
how you can evaluate the expression without know what use of a variable
is feeding the PHI...

Andrew




More information about the Gcc mailing list