From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21667 invoked by alias); 26 Mar 2004 19:54:51 -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 20742 invoked from network); 26 Mar 2004 19:54:44 -0000 Received: from unknown (HELO mail0.lsil.com) (147.145.40.20) by sources.redhat.com with SMTP; 26 Mar 2004 19:54:44 -0000 Received: from milmhbs0.lsil.com (mhbs.lsil.com [147.145.1.30]) by mail0.lsil.com (8.12.8/8.12.8) with ESMTP id i2QJsflW008238 for ; Fri, 26 Mar 2004 11:54:41 -0800 (PST) Received: from dts0.lsil.com (dts0.lsil.com [147.145.146.6]) by milmhbs0.lsil.com (8.12.11/8.12.10) with ESMTP id i2QJuanL008538 for ; Fri, 26 Mar 2004 11:56:36 -0800 Received: from dt219 (dt219 [147.145.146.219]) by dts0.lsil.com (8.11.6+Sun/8.11.6) with SMTP id i2QJsfT27909 for ; Fri, 26 Mar 2004 13:54:42 -0600 (CST) Message-Id: <200403261954.i2QJsfT27909@dts0.lsil.com> Date: Fri, 26 Mar 2004 22:21:00 -0000 From: John Lu Reply-To: John Lu Subject: Register Allocation To: gcc@gcc.gnu.org MIME-Version: 1.0 Content-Type: TEXT/plain; charset=us-ascii Content-MD5: gKnPOdIRaZop6R8++oc4pg== X-Scanned-By: MIMEDefang 2.39 X-SW-Source: 2004-03/txt/msg01579.txt.bz2 Hi, I've been working on a port based on gcc-3.3 and I've noticed that better assembly code is generated if the C source has separate variables declared for distinct live ranges. For example, int foo1(int *p1, int *p2) { int i; /* one index variable for two live ranges */ int total; total=0; for (i=0; i<100; i++) { total+=p1[i]; } for (i=0; i<100; i+=2) { total+=p1[i]; } return(total); } produces worse code than: int foo2(int *p1, int *p2) { int i1,i2; /* two index variables for two live ranges */ int total; total=0; for (i1=0; i1<100; i1++) { total+=p1[i1]; } for (i2=0; i2<100; i2+=2) { total+=p1[i2]; } return(total); } In my port, i1 is allocated a loop register which supports faster looping, and i2 is allocated to a gpr because a decrement by two is needed. When only one index variable is declared, "i" is allocated to a loop register, but this creates bad code for the second loop, since decrement by two is not supported for loop registers. This happens with and without the "-fnew-ra" option. I was wondering if anyone else has seen this or am I doing something wrong in my port. Thanks, John Lu