PPC64 Compiler bug !!

Anton Blanchard anton at samba.org
Fri Jun 13 23:53:56 EST 2003


> But we do want "discourage use of FPRs for DImode".  User code will
> incur an exception on first use of a FPR.  That means GPRs are cheaper
> to use than FPRs for moving blocks of memory under Linux.

For the non believers in the audience try the following program. It
forces a context switch (to unlazy the FPU), then times how long a
lfd takes.

eg on a POWER4 box (timebase ticks at 1/8 processor frequency), I got

139, 420, 133, 202, 186

So best case was over 1000 processor cycles. Ouch.

Anton

static inline unsigned long read_tsc(void)
{
	unsigned long tmp;
	asm volatile("mftb %0" : "=r" (tmp));
	return tmp;
}

int main()
{
	unsigned long before, after;
	double foo;
	unsigned long bar;
	unsigned long long blah;

	/* force a context switch */
	sleep(1);

	before = read_tsc();
#if 1
	asm volatile("lfd	%0, %1" :"=f"(foo) : "m"(blah));
#else
	asm volatile("lwz	%0, %1": "=r"(bar) : "m"(blah));
#endif
	after = read_tsc();

	printf("%d timebase ticks\n", after - before);
}


** Sent via the linuxppc64-dev mail list. See http://lists.linuxppc.org/





More information about the Linuxppc64-dev mailing list