[cairo] Speeding up _cairo_fixed_from_double

Jamey Sharp jamey at minilop.net
Sun Oct 29 22:42:27 PST 2006


On Sun, Oct 29, 2006 at 08:12:48PM -0500, Jim Gettys wrote:
> It should be.  The man page refers to dead code elimination (dce) being
> the default at -O or higher.

Sadly, GCC isn't recognizing that as dead code, so it can't eliminate
it. With -O, the version of GCC I tested [1] does some remarkable tricks
to eliminate branches, but still checks endianness at runtime. I tested
this C:

	int endian = 1;
	if (*(char *) &endian)
		return '\154'; /* 'l' */
	else
		return '\102'; /* 'B' */

GCC produced this x86 assembly:

	movl    $1, %eax
	movl    %eax, 12(%esp)
	cmpb    $1, 12(%esp)
	sbbl    %eax, %eax
	andl    $-42, %eax
	addl    $108, %eax

Impressive, but not what was desired.

--Jamey

[1] GCC: (GNU) 4.1.2 20060901 (prerelease) (Debian 4.1.1-13)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.freedesktop.org/archives/cairo/attachments/20061029/d2346d26/attachment.pgp


More information about the cairo mailing list