Subject: Re: B19: gcc optimizer generates bad code
From: [email-masked]

25 Mar 1998 06:53:43 -0800
Message-ID: <[email-masked]>
Mime-Version: 1.0
Content-Type: text/plain; charset=cp850
Content-Transfer-Encoding: 8bit
To: [email-masked]

Congratulations. You've discovered the O2 bug.  Use
-fno-strength-reduce and drink lots of fluids.

>   Tom Uban ([email-masked])
>   Thu, 19 Mar 1998 12:12:20 -0600
>/*
> * When this simple code sample is compiled with the Cygnus B19.1 gcc
> * compiler using either -O2 or -O3, bad code is generated.
> *      gcc -O2 test.c
> *  or
> *      gcc -O3 test.c
> *
> * This program should always print the number 4. When compiled
> * with -O2 or -O3 the number 1 is printed. The dissassembled output
> * seems to indicate that the loop code generation is broken.
> *
> * The result of gcc -v is:
> *      Reading specs from
>C:\CYGNUS\B19\H-I386~1\lib\gcc-lib\i386-cygwin32\2.7-B19\specs
> *      gcc driver version 2.7-B19 executing gcc version 2.7-97r2aBeta
> *
> * The Cygnus B18 (gcc version cygnus-2.7.2-970404) release did not
> * exhibit this behavior.
> *
> * Tom Uban - 17 March 1998
> * [email-masked]
> */
>unsigned short foobar = 1;
>
>main()
>{
>        unsigned short *sptr = &foobar;
>        unsigned long cksum;
>        int i;
>
>        cksum = 0;
>
>        for (i = 0; i < 4; i++)
>                cksum += *sptr;
>
>        printf("%d\n", cksum);
>}

-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".