This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: Loop unrolling Problem !!
- From: Peter Barada <pbarada at mail dot wm dot sps dot mot dot com>
- To: chang at totoro dot ee dot ntust dot edu dot tw
- Cc: binutils at sources dot redhat dot com
- Date: Wed, 24 Jul 2002 10:20:13 -0400
- Subject: Re: Loop unrolling Problem !!
- References: <Pine.LNX.4.33.0207241517390.21491-100000@totoro.ee.ntust.edu.tw>
>I compiler the source main.c with m68k-elf-gcc(gcc-3.0.4 and binutils-2.12)
>and dissemble the binary file, we can find that the code inside the
>infinte
>loop while(1) j = 10 and i = 10 have two copy in binary file.
>Is there any option to avoid this kind of duplication and
>where to find the source related with.
>
>
>thanks,
>
>By the way, I compiled the source with following command
>m68k-elf-gcc -m68000 -nostartfiles -gstabs+ -nostdlib -fno-unroll-loops -c
>main.c
>
>SOURCE: main.c
>================================
>main ()
>{
> int j = 10;
> int i = 10;
> while(1)
> {
> j = 10;
> i = 10;
> }
>
>}
>
If you turn the optimizer on(by adding -O2):
m68k-elf-gcc -O2 -m68000 -nostartfiles -gstabs+ -nostdlib -fno-unroll-loops -c
You should see something like:
00000000 <main>:
0: 4e56 0000 linkw %fp,#0
4: 60fe bras 4 <main+0x4>
6: 4e71 nop
The optimizer determined that the assignments had no effect outside
the scope of the function, so it wiped them out. Do you have a better
testcase that shows a problem with the optimizer tuirned *on*?
--
Peter Barada Peter.Barada@motorola.com
Wizard 781-852-2768 (direct)
WaveMark Solutions(wholly owned by Motorola) 781-270-0193 (fax)