public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Simple loops not interchanged?
@ 2004-12-10 15:36 Richard Guenther
  2004-12-10 16:21 ` Andrew Pinski
  2004-12-10 16:34 ` Daniel Berlin
  0 siblings, 2 replies; 9+ messages in thread
From: Richard Guenther @ 2004-12-10 15:36 UTC (permalink / raw)
  To: gcc

Hi!

I expected -ftree-loop-linear to exchange loops in

double foo(double *a)
{
        int i,j;
        double r = 0.0;
	for (i=0; i<8; ++i)
                for (j=0; j<8; ++j)
			r += a[j*8+i];
        return r;
}

but it tells me (regardless of loop order) that
"Won't transform loop. Optimal transform is the identity transform"
which I cannot believe, obviously.

From further experiments, if I don't pass a as a function parameter,
but make its declaration globally available, the transform succeeds.

The main difference in tree dumps before the transformation attempt
is the data access:

 <L1>:;
   D.1129_12 = j_4 * 8;
   D.1130_13 = i_3 + D.1129_12;
-  D.1131_14 = (unsigned int) D.1130_13;
-  D.1132_15 = D.1131_14 * 8;
-  D.1133_16 = (double *) D.1132_15;
-  D.1134_18 = D.1133_16 + a_17;
-  D.1135_19 = *D.1134_18;
+  D.1131_15 = a[D.1130_13];
   r_6 = r_5 + D.1131_15;
   j_17 = j_4 + 1;
   if (N_7 > j_17) goto <L16>; else goto <L3>;

which is just D.1131_15 = a[D.1130_13] in case of the global.  Note
that is the difference starting from the generic tree dump.

What's going wrong here?

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] 9+ messages in thread
* Re: [autovect][PATCH]: Re: Simple loops not interchanged?
@ 2004-12-12 15:16 Dorit Naishlos
  0 siblings, 0 replies; 9+ messages in thread
From: Dorit Naishlos @ 2004-12-12 15:16 UTC (permalink / raw)
  To: Daniel Berlin; +Cc: gcc, Richard Guenther, Sebastian Pop





> i'd like to
> apply this to the autovect branch (Feel free to use
> evolution_function_is_invariant_p in the tests in the vectorizer. It
> should let you catch some more loops than the simple constant test, if
> you can transform them properly)

sure. thanks,

dorit




                                                                                                                                     
                      Daniel Berlin                                                                                                  
                      <dberlin@dberlin.        To:       Richard Guenther <rguenth@tat.physik.uni-tuebingen.de>, Sebastian Pop       
                      org>                      <sebastian.pop@cri.ensmp.fr>, Dorit Naishlos/Haifa/IBM@IBMIL                         
                      Sent by:                 cc:       gcc@gcc.gnu.org                                                             
                      gcc-owner@gcc.gnu        Subject:  [autovect][PATCH]: Re: Simple loops not interchanged?                       
                      .org                                                                                                           
                                                                                                                                     
                                                                                                                                     
                      12/12/2004 05:58                                                                                               
                                                                                                                                     





I've attached a patch that lets us interchange this.
It does two things:

1. It lets the chrec code consider variables invariant in the loop that
matches the chrec variable (loop number) as constant for purposes for the
chrec.

2. It informs the data dependence tester that chrecs that are equal
(ie the same chrec) overlap on every iteration.

This is enough to get this loop to interchange.

Sebastian, unless you have a problem with this, then Dorit, i'd like to
apply this to the autovect branch (Feel free to use
evolution_function_is_invariant_p in the tests in the vectorizer. It
should let you catch some more loops than the simple constant test, if
you can transform them properly)

It includes Richard's testcase in order to make sure we don't regress here
later on.

:)




#### dataref.diff has been removed from this note on December 12, 2004 by
Dorit Naishlos

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

end of thread, other threads:[~2004-12-13  9:46 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-10 15:36 Simple loops not interchanged? Richard Guenther
2004-12-10 16:21 ` Andrew Pinski
2004-12-10 16:39   ` Daniel Berlin
2004-12-10 16:34 ` Daniel Berlin
2004-12-12  3:58   ` [autovect][PATCH]: " Daniel Berlin
2004-12-12 17:59     ` Devang Patel
2004-12-12 18:02       ` Daniel Berlin
2004-12-13  9:46     ` Sebastian Pop
2004-12-12 15:16 Dorit Naishlos

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).