Loop unrolling Problem !!

Aladdin Chang chang@totoro.ee.ntust.edu.tw
Wed Jul 24 21:10:00 GMT 2002


On Wed, 24 Jul 2002, Peter Barada wrote:

> 
> >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*?
> 
> 

i, 
thanks your help,

I know that the optimazation will solve this problem,
but I am going to development a source level debugging tool(link gdb).
if the code within an loop will be duplicate when specify -O0 ,
I have no idea how to implement the break point, because the same source
line will be map to more than one address in binary code in stabs debug
information.

if possible, will you give me a hand to tell me where the source 
related with this loop unrolling.

thanks in advance.

Aladdin



More information about the Binutils mailing list