This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC] [parloop branch] Supporting reductions for automatic parallelization


Hello,

> > Note that in the above, it is not the fact that all variables are
> > named "sum" that make this a reduction.
> > I could write it
> > 
> > L0:
> > sum_0 = phi (0, foo_37)
> > ...
> > 
> > foo_37 = sum_0 + something
> > (goto L0)
> > 
> > and it would still be a reduction.
> >
> 
> No, not all varibales have to be named the same, but there is one 
> variable which is the reduction variable, isn't there? does it even
> make sense to have a "reduction variable", which would actually be the 
> variable accumulating the values (or holding any other reduction result)? 
> (in this case, it would be foo) 
> 
> So What I mean is, that each reduction can be reduced to 
> 
> L0:
> old_value = phi <reduction_ssa, inial_value>
> reduction_ssa = old_value + something 
> goto L0 
> 
> and SSA_NAME_VAR (reduction_ssa) is the reduction variable. 
>
> Is that true, or is this an aqward way of looking at it?

the point is that SSA_NAME_VAR is completely irrelevant.  SSA names
with different SSA_NAME_VARs may be used to define a reduction variable,
while SSA names with the same SSA_NAME_VAR may be completely unrelated.
In particular, I think your current code would cause misscompilation in
the following case:

while (1)
  {
    sum_1 = phi (0, sum_2);
    sum_2 = sum_1 + something;
    sum_3 = something_completely_different;
  }
result_4 = phi (sum_3)
return result_4;

As it would believe that sum_3 is a reduction variable, because sum_1
is.

Zdenek


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]