Actions

icon Post
text/html Subscribe
text/html Unsubscribe

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [coldfire-gnu-discuss] Toolchain, asm parameters numbering and optimisation flags


  • To: fred@xxxxxxxxxxxx
  • Subject: Re: [coldfire-gnu-discuss] Toolchain, asm parameters numbering and optimisation flags
  • From: Nathan Sidwell <nathan@xxxxxxxxxxxxxxxx>
  • Date: Tue, 05 Dec 2006 13:18:44 +0000

fred@xxxxxxxxxxxx wrote:
Hello,

I'm just trying to optimize the speex codec for the coldfire CPU.
Using the CodeSourcery toolchain, I have strange behaviour (I think)
of GCC.
I've attached the C source code, then the results of :
m68k-uclinux-gcc -Wa,--register-prefix-optional -Wa,-memac -Wa,-mcpu=5208
-mcpu=5208  -O2 -S -o test.O2.s test.c

    35	: "=d" (sum)
    36	: "a"(x), "a"(y), "d"(len), "d"(t1), "d"(t2), "d"(t3)
    37	:"cc"

Here's your problem. The inline asm semantics are that all the input operands are read before any of the output operands are written. thus it is safe to allocate the same register(s) for inputs and outputs. All gcc targets are the same in this regard. Your assembly breaks that. you can fix this by telling gcc that 'sum' is an early clobber
	:"=&d" (sum)

I notice that you are also modifying the input operands. That's breaking the semantics too. the compiler will presume the register it placed 'len' into before the asm has the same value after the asm. IIRC you indicate this altering of input values by making them output operands, but using a + rather than an =.

oh, you don't need the -Wa,-memac -Wa,-mcpu=5208 flags. The latter flag implies the former, and the compiler's -mcpu=5208 option is passed through to the assembler anyway (besides telling the compiler that you're targetting a 5208).

nathan

--
Nathan Sidwell    ::   http://www.codesourcery.com   ::         CodeSourcery
nathan@xxxxxxxxxxxxxxxx    ::     http://www.planetfall.pwp.blueyonder.co.uk