From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22593 invoked by alias); 27 Nov 2001 08:02:37 -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 22423 invoked from network); 27 Nov 2001 08:02:31 -0000 Received: from unknown (HELO dot.cygnus.com) (205.180.230.224) by hostedprojects.ges.redhat.com with SMTP; 27 Nov 2001 08:02:31 -0000 Received: (from rth@localhost) by dot.cygnus.com (8.11.2/8.11.2) id fAR81os29747; Tue, 27 Nov 2001 00:01:50 -0800 X-Authentication-Warning: dot.cygnus.com: rth set sender to rth@redhat.com using -f Date: Sun, 18 Nov 2001 09:18:00 -0000 From: Richard Henderson To: Andreas Schwab Cc: Corey Minyard , gcc@gcc.gnu.org Subject: Re: Loop optimization bug with Ada front end on PPC (and probably Alpha) Message-ID: <20011127000150.A29737@redhat.com> Mail-Followup-To: Richard Henderson , Andreas Schwab , Corey Minyard , gcc@gcc.gnu.org References: <3BFCA770.5070304@acm.org> <20011124124100.A2485@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from schwab@suse.de on Sun, Nov 25, 2001 at 05:57:07PM +0100 X-SW-Source: 2001-11/txt/msg00825.txt.bz2 I've committed the following simplification as execute/20011126-2.c. r~ /* Problem originally visible on ia64. There is a partial redundancy of "in + 1" that makes GCSE want to transform the final while loop to p = in + 1; tmp = p; ... goto start; top: tmp = tmp + 1; start: in = tmp; if (in < p) goto top; We miscalculate the number of loop iterations as (p - tmp) = 0 instead of (p - in) = 1, which results in overflow in the doloop optimization. */ static const char * test (const char *in, char *out) { while (1) { if (*in == 'a') { const char *p = in + 1; while (*p == 'x') ++p; if (*p == 'b') return p; while (in < p) *out++ = *in++; } } } int main () { char out[4]; test ("aab", out); return 0; } From mboxrd@z Thu Jan 1 00:00:00 1970 From: Richard Henderson To: Andreas Schwab Cc: Corey Minyard , gcc@gcc.gnu.org Subject: Re: Loop optimization bug with Ada front end on PPC (and probably Alpha) Date: Tue, 27 Nov 2001 00:02:00 -0000 Message-ID: <20011127000150.A29737@redhat.com> References: <3BFCA770.5070304@acm.org> <20011124124100.A2485@redhat.com> X-SW-Source: 2001-11/msg01329.html Message-ID: <20011127000200.MK3w2Fb_qKJng9ZLAT8RHX27zCmXHNPILkR-lSOFVcM@z> I've committed the following simplification as execute/20011126-2.c. r~ /* Problem originally visible on ia64. There is a partial redundancy of "in + 1" that makes GCSE want to transform the final while loop to p = in + 1; tmp = p; ... goto start; top: tmp = tmp + 1; start: in = tmp; if (in < p) goto top; We miscalculate the number of loop iterations as (p - tmp) = 0 instead of (p - in) = 1, which results in overflow in the doloop optimization. */ static const char * test (const char *in, char *out) { while (1) { if (*in == 'a') { const char *p = in + 1; while (*p == 'x') ++p; if (*p == 'b') return p; while (in < p) *out++ = *in++; } } } int main () { char out[4]; test ("aab", out); return 0; }