This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Loop unrolling Problem !!


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]