From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7819 invoked by alias); 13 Dec 2002 13:46:04 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 7718 invoked by uid 71); 13 Dec 2002 13:46:03 -0000 Date: Fri, 13 Dec 2002 05:46:00 -0000 Message-ID: <20021213134603.7705.qmail@sources.redhat.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: "Christian Ehrhardt" Subject: Re: optimization/7799: [3.2/3.3 regression] Loop bug with optimization flag -Os in gcc Reply-To: "Christian Ehrhardt" X-SW-Source: 2002-12/txt/msg00748.txt.bz2 List-Id: The following reply was made to PR optimization/7799; it has been noted by GNATS. From: "Christian Ehrhardt" To: nejataydin@superonline.com, gcc-gnats@gcc.gnu.org, gcc@gcc.gnu.org, gcc-bugs@gcc.gnu.org, nobody@gcc.gnu.org Cc: Subject: Re: optimization/7799: [3.2/3.3 regression] Loop bug with optimization flag -Os in gcc Date: Fri, 13 Dec 2002 14:36:26 +0100 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7799 Hi, this PR is about the following code snippet that is miscompiled with -Os void fill (int* p, int* q[10]) { int i; for (i = 0; i < 10; i++) *q++ = &p[i]; } The asm-Code is this: pushl %ebp movl %esp, %ebp movl 8(%ebp), %eax movl 12(%ebp), %edx leal 36(%eax), %ecx .L6: movl %eax, (%edx) addl $4, %eax addl $4, %edx cmpl %ecx, %eax jle .L6 popl %ebp ret This code roughly corresponds to the following C-Code: void fill (int * p, int *q[10]) { int ecx = (int)p + 9; do { *q = p; p++; q++; } while ((int)p <= ecx); } This transformation is IMHO illegal because there is no way to make the comparison in general equivialent to that in the original for loop. If p is initially 0x7ffffffc the comparison must be treated as unsigned, however, if p is initially 0xfffffffc the comparison must be treated as signed. regards Christian -- THAT'S ALL FOLKS!