www.delorie.com/archives/browse.cgi   search  
Mail Archives: pgcc/1999/09/16/19:41:12

Date: Thu, 16 Sep 1999 18:10:09 +0100
From: Simon Taylor <simon AT aingarth-taylor DOT freeserve DOT co DOT uk>
To: pgcc AT delorie DOT com
Subject: Optimizer bug
Message-ID: <19990916181009.A7224@aingarth-taylor.freeserve.co.uk>
Mime-Version: 1.0
X-Mailer: Mutt 1.0pre2i
Reply-To: pgcc AT delorie DOT com

PGCC generates incorrect code for the file pgcc_bug.c when invoked with
the following options:

pgcc -S -O -fstrength-reduce -fcompare-elim pgcc_bug.c

== pgcc_bug.c
int main(void)
{
        int i;
        int h[3];
        h[0]=0;
        for (i=0; i<2; i++)
                h[i+1]=h[i];

        return 0;
}

The following assembly output is produced:

== pgcc_bug.s
        .file   "pgcc_bug.c"
        .version        "01.01"
gcc2_compiled.:
.text
        .align 16
.globl main
        .type    main,@function
main:
        pushl %ebp
        movl %esp,%ebp
        subl $52,%esp
        pushl %ebx
        movl $0,-32(%ebp)
        movl $-2,%edx
        leal -32(%ebp),%ebx
        movl $4,%ecx
        .p2align 4,,7
.L6:
        movl 8(%ebx,%edx,4),%eax
        movl %eax,(%ecx,%ebx)
        addl $4,%ecx
        addl $3,%edx
        jne .L6
        xorl %eax,%eax
        popl %ebx
        movl %ebp,%esp
        popl %ebp
        ret
.Lfe1:
        .size    main,.Lfe1-main
        .ident  "GCC: (GNU) pgcc-2.95.1 19990816 (release)"

I am using PGCC 2.95.1 under Linux 2.2.12 on a Pentium Pro.

-- 
Simon Taylor

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019