This is the mail archive of the 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 !!

>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
>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.
>By the way, I compiled the source with following command
>m68k-elf-gcc -m68000 -nostartfiles -gstabs+ -nostdlib -fno-unroll-loops  -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                         
Wizard                                         781-852-2768 (direct)
WaveMark Solutions(wholly owned by Motorola)   781-270-0193 (fax)

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