public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* [tree-ssa] Write to global memory not hoisted out of loop
@ 2004-04-30 16:23 Richard Guenther
  2004-04-30 16:25 ` Steven Bosscher
  0 siblings, 1 reply; 7+ messages in thread
From: Richard Guenther @ 2004-04-30 16:23 UTC (permalink / raw)
  To: gcc

Hi!

Writes to global memory are not hoisted out of a computation loop. F.e.

double tmp;
void foo(double * __restrict__ x, double * __restrict__ y, double *
__restrict__ z, int n)
{
  int i;
  for (i=0; i<n; ++i) {
    tmp = y[i]*z[i];
    x[i] = tmp;
  }
}

is compiled to (-O2 -fno-trapping-math):

...
.L4:
        leal    0(,%edx,8), %eax        #, tmp66
        incl    %edx    # i
        fldl    (%eax,%ebx)     #* z
        cmpl    %ecx, %edx      # n, i
        fmull   (%eax,%esi)     #* y
        fstl    tmp     # tmp
        fstpl   (%eax,%edi)     #* x
        jl      .L4     #,
...

note that the load from tmp is optimized, but the store is still inside
the loop.  The store would be necessary in case of trapping math
operations to make side-effects visible, but I thought, -fno-trapping-math
should get rid of it.  Making tmp static doesn't help either, while here
removing the store would be valid even in case of trapping math.  Turning
on points-to doesn't help either.  Intel compiler moves the store in any
case (which seems to be a bug).

Is there already a PR about this pessimization? (Couldn't find one)

Richard.

--
Richard Guenther <richard dot guenther at uni-tuebingen dot de>
WWW: http://www.tat.physik.uni-tuebingen.de/~rguenth/

^ permalink raw reply	[flat|nested] 7+ messages in thread
* Re: [tree-ssa] Write to global memory not hoisted out of loop
@ 2004-04-30 22:28 Richard Kenner
  2004-04-30 22:28 ` Diego Novillo
  0 siblings, 1 reply; 7+ messages in thread
From: Richard Kenner @ 2004-04-30 22:28 UTC (permalink / raw)
  To: dnovillo; +Cc: gcc

    Correct.  We don't check restricted pointers.  This is another item in
    my post merge todo.

Do you call the normal get_alias_set code?  Is TYPE_REF_CAN_ALIAS_ALL
respected?

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2004-04-30 21:27 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-30 16:23 [tree-ssa] Write to global memory not hoisted out of loop Richard Guenther
2004-04-30 16:25 ` Steven Bosscher
2004-04-30 16:26   ` Richard Guenther
2004-04-30 22:25     ` Zdenek Dvorak
2004-04-30 22:26       ` Diego Novillo
2004-04-30 22:28 Richard Kenner
2004-04-30 22:28 ` Diego Novillo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).