Hi,

On Mon, 22 Oct 2007, Tomash Brechko wrote:

> On Mon, Oct 22, 2007 at 14:53:41 +0100, Dave Korn wrote:
> > The optimisation the compiler is making here is a big win in normal
> > code, you wouldn't want to disable it unless absolutely necessary;
> > to be precise, you wouldn't want to automatically disable it for
> > every loop and variable in a program that used -fopenmp just because
> > /some/ of the variables in that program couldn't be safely accessed
> > that way.
> 
> I'd rather wish the optimization would be done differently.  Currently
> we have:
> 
>                                          mem -> reg;
>    loop                                  loop
>      if (condition)    => optimize =>      if (condition)
>        val -> mem;                           val -> reg;
>                                          reg -> mem;
> 
> 
> But it could use additional register and be:
> 
>                                          0 -> flag_reg;
>                                          loop
>                                            if (condition)
>                                              val -> reg;
>                                              1 -> flag_reg;
>                                          if (flag_reg == 1)
>                                            reg -> mem;

That could be done but would be besides the point.  You traded one 
conditional store with another one, so you've gained nothing in that 
transformation.  The point of this transformation is precisely to get rid 
of that conditional store (enabling for instance other transformations as 
easier store sinking).  That sometimes gains _much_ performance, so 
something we want to do in all cases where it's possible.  You really have 
to protect your data access itself, or make those data accesses volatile, 
there's no way around this.


Ciao,
Michael.

Reply via email to