Code gen error on PowerPC

Gary Thomas gdt@linuxppc.org
Sun Feb 28 23:30:00 GMT 1999


BTW - I've tested this against the mainline compiler (egcs-2.93.09 19990223)
and it generates quite different, but correct, code for this example.

On 22-Feb-99 Gary Thomas wrote:
> With EGCS-1.1.2-pre1 (and indeed before, this is not a regression)
> I have the following code generation problem:
> 
> The attached program (test.c) fails when compiled with -O2.  This
> is [I believe] a strength reduction bug (-fno-strength-reduce eliminates
> the problem).
> 
> [gary@Ares glade]$ gcc -B/usr/src/redhat/BUILD/egcs-1.1.2-pre1/gcc/ -Wall -o test test.c -dapA -O2 -save-temps
> test.c: In function `init_widget':
> test.c:54: warning: implicit declaration of function `printf'
> test.c: At top level:
> test.c:58: warning: return-type defaults to `int'
> test.c: In function `main':
> test.c:81: warning: control reaches end of non-void function
> [gary@Ares glade]$ ./test
> init section 0
> init: widget 0.0
> init: widget 1.1
> init: widget 2.2
> Segmentation fault
> 
> Here's the proper behaviour:
> [gary@Ares /tmp]$ gcc -B/usr/src/redhat/BUILD/egcs-1.1.2-pre1/gcc/ -Wall -o test test.c -O2 -fno-strength-reduce
> test.c: In function `init_widget':
> test.c:54: warning: implicit declaration of function `printf'
> test.c: At top level:
> test.c:58: warning: return-type defaults to `int'
> test.c: In function `main':
> test.c:81: warning: control reaches end of non-void function
> [gary@Ares /tmp]$ ./test
> init section 0
> init: widget 0.0
> init: widget 0.1
> init: widget 0.2
> init section 1
> init: widget 1.0
> init: widget 1.1
> init: widget 1.2
> init section 2
> init: widget 2.0
> init: widget 2.1
> init: widget 2.2
> 
> During 'loop', it finds a GIV on line 74:
>             gwid = &sec->widgets[j];
> as:
> Insn 71: dest address src reg 81 benefit 7 used 1 lifetime 1 
>          replaceable mult 8 add (plus:SI (plus:SI (reg:SI 88)
> 
> This would be fine except that the (sec->widgets) part is
> later realized as:
> .L9:
>         lwzu 9,8(30)  # 71 *movsi_update1/2
> Since this is inside the loop (.L9), the value of (sec->widgets)
> [8(30)] is different every time through the loop.
> 
> I think the problem is that the GIV calculation looked beyond the
> top of the loop to find this to insn #161. The error occurs when
> this computation is brought inside the loop.
> 
> 
> 
> 
> 
> 



More information about the Gcc-bugs mailing list