[cairo] [PATCH] Altivec optimizations

Baz brian.ewins at gmail.com
Thu Mar 8 17:19:25 PST 2007

On 17/02/07, Luca Barbato <lu_zero at gentoo.org> wrote:
> I completed the fbcompose part the regtest are consistent, hopefully
> I'll start adding the pict ops later in the next week.
> lu

The patch fails to compile on apple:

 /usr/libexec/gcc/powerpc-apple-darwin8/4.0.1/cc1 -fpreprocessed
fbpict.i -fPIC -quiet -dumpbase fbpict.c -auxbase-strip .libs/fbpict.o
-Wall -Wextra -Wsign-compare -Werror-implicit-function-declaration
-Wpointer-arith -Wwrite-strings -Wstrict-prototypes
-Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Wpacked
-Wswitch-enum -Wmissing-format-attribute -Wstrict-aliasing=2
-Winit-self -Wdeclaration-after-statement -Wold-style-definition
-Wno-missing-field-initializers -Wno-unused-parameter -version
-fno-common -o fbpict.s
GNU C version 4.0.1 (Apple Computer, Inc. build 5247) (powerpc-apple-darwin8)
        compiled by GNU C version 4.0.1 (Apple Computer, Inc. build 5247).
GGC heuristics: --param ggc-min-expand=65 --param ggc-min-heapsize=65536
Compiler executable checksum: 293c7bb043389dbe08b10e2d17bba0c4
 as -arch ppc -o .libs/fbpict.o fbpict.s
fbpict.s:9430:Parameter syntax error (parameter 1)
make[3]: *** [fbpict.lo] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1

The offending line was 'vor 0, 0, 0', from your VMX detection code. I
fixed it up using VMX detection from apples docs as below, seems to be
working now - make check seems ok, now I need to run the perf tests.
More later.

#ifdef __APPLE__
#include <sys/sysctl.h>

Bool fbHaveVMX(void) {
  int hasVMX = 0;
  size_t length = sizeof( hasVMX );
  int error = sysctlbyname("hw.optional.altivec", &hasVMX, &length, NULL, 0);
  if( 0 != error ) return 0;
  return hasVMX;

#include <signal.h>
#include <setjmp.h>

static sigjmp_buf jmp;
static volatile sig_atomic_t in_test = 0;

static void vmx_test (int sig) {
    if (!in_test) {
        signal(sig, SIG_DFL);
        raise (sig);
    in_test = 0;
    siglongjmp (jmp, 1);

Bool fbHaveVMX(void) {
    signal (SIGILL, vmx_test);
    if (sigsetjmp (jmp, 1)) {
        signal (SIGILL, SIG_DFL);
    } else {
        in_test = 1;
        asm volatile ( "vor 0, 0, 0" );
        signal (SIGILL, SIG_DFL);
        return 1;
    return 0;
#endif /* __APPLE__ */
#endif //USE_VMX

More information about the cairo mailing list