This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Loop unrolling and asm
- To: chris at lslsun dot epfl dot ch (Christian Iseli)
- Subject: Re: Loop unrolling and asm
- From: Joern Rennecke <amylaar at cygnus dot co dot uk>
- Date: Tue, 10 Mar 1998 17:11:18 +0000 (GMT)
- Cc: egcs at cygnus dot com
> Hi folks,
>
> While trying out egcs-1.0.2-prerelease, I compiled the
> new XFree86-3.3.2 on a Linux 2.1.88 (RH 5.0) PPro box.
> binutils-2.8.(...).21 is installed.
>
> I used -O2 -march=i686 -funroll-loops to compile XFree.
> I encountered a small problem where a loop containing asm
> was unrolled. The asm included labels (.label00, .label01, ...)
> and the assembler died because of multiple definitions of
> the labels.
>
> The problem, of course, went away when I recompiled the incriminated
> file without loop unrolling.
>
> XFree seems to run fine.
>
> Now the question: how do you go about including an asm with labels
> in a loop that will be unrolled?
There are two ways to do this:
- local labels
Not all assemblers support these, but at least gnu as does. You define
a local label as <digit>: , and reference it as <digit>b for a backwards
reference, or <digit>f for a forwards reference. E.g.:
0:
add -1,r0
bne 0b
- using "%=" in the assembler template. This will expand to a number
which is unique to the template as seen by final_scan_insn. That is,
for each copy that final_scan_insn created, you will get a different
number.