Re: GCC asm block optimizations on x86_64

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

 



On Mon, Aug 27, 2007 at 06:11:04AM +0100, Darryl L. Miles wrote:
> 	#define U64_DIVIDE_ASM(quotient, remainder, dividend, divisor, overflow)	do {	\
> 		__asm__ __volatile__(						\
> 			"\n\t"							\
> 			"xorl %0,%0\n\t"					\
> 			"divq %5\n\t"						\
> 										\
> 			"jnc 1f\n\t"						\
> 			"incl %0\n"						\
> 			"1:\n\t"						\
> 			"movq %%rax,%2\n\t"					\
> 			"movq %%rdx,%1\n\t"					\
> 			: "=&g" (overflow),		/* return */		\
> 			  "=g" (*remainder),					\
> 			  "=g" (*quotient)					\
> 			: "d" (0),			/* argument */		\
> 			  "a" ((*dividend)),					\
> 			  "g" ((*divisor))					\
> 			/*: "rax", "rdx", you'd think you need this to */	\
> 			/* describe these registers as no longer containing */	\
> 			/* the assigned input values after asm block */		\
> 			/* execution, but will not compile witht them set. */	\

   I think you want

: "=&r" (overflow),	/* return */
  "=d" (*remainder),
  "=a" (*quotient)
: "1" (0),		/* argument */
  "2" (*dividend),
  "rm" (*divisor)

so the compiler knows that %rax and %rdx are modified.

-- 
Rask Ingemann Lambertsen

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux