From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7188 invoked by alias); 10 Dec 2004 15:36:46 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 6717 invoked from network); 10 Dec 2004 15:36:36 -0000 Received: from unknown (HELO alwazn.tat.physik.uni-tuebingen.de) (134.2.170.157) by sourceware.org with SMTP; 10 Dec 2004 15:36:36 -0000 Received: by alwazn.tat.physik.uni-tuebingen.de (Postfix, from userid 30023) id E02133FA1; Fri, 10 Dec 2004 16:36:35 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by alwazn.tat.physik.uni-tuebingen.de (Postfix) with ESMTP id D7F3A76988 for ; Fri, 10 Dec 2004 16:36:35 +0100 (CET) Date: Fri, 10 Dec 2004 15:36:00 -0000 From: Richard Guenther To: gcc@gcc.gnu.org Subject: Simple loops not interchanged? Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-SW-Source: 2004-12/txt/msg00360.txt.bz2 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: :; 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 ; else goto ; 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 WWW: http://www.tat.physik.uni-tuebingen.de/~rguenth/