Re: patch_v2: (on Alpha) emulating missing instructions


Subject: Re: patch_v2: (on Alpha) emulating missing instructions
From: Robert Harley (Robert.Harley@inria.fr)
Date: Mon Oct 18 1999 - 07:46:59 PDT


BTW, here is a fast and short way of doing minuw():

------------------------------------------------------------------------------
#define CMPBGE(a, b, c) \
  asm("cmpbge %1, %2, %0" : "=r" (c) : "r" (a), "r" (b))
#define ZAP(a, b, c) \
  asm("zap %1, %2, %0" : "=r" (c) : "r" (a), "r" (b))
#define ZAPNOT(a, b, c) \
  asm("zapnot %1, %2, %0" : "=r" (c) : "r" (a), "r" (b))

static u64 minuw(u64 x, u64 y) {
  u64 eq, ge1, ge2;

  CMPBGE(x, y, ge1);
  CMPBGE(0, x ^ y, eq);

  ge2 = (ge1 & ~eq | eq & ge1<<1) & 0xAA;
  ge2 |= ge2>>1;

  ZAP(x, ge2, x);
  ZAPNOT(y, ge2, y);

  return x | y;
} /* end function minuw */
------------------------------------------------------------------------------

The output from gcc 2.95 looks like:

------------------------------------------------------------------------------
minuw:
        cmpbge $16, $17, $1
        xor $16,$17,$3
        mov $31,$2
        cmpbge $2, $3, $2
        addq $1,$1,$4
        bic $1,$2,$1
        and $2,$4,$2
        bis $1,$2,$1
        and $1,170,$1
        srl $1,1,$2
        bis $1,$2,$1
        zapnot $17, $1, $17
        zap $16, $1, $16
        bis $16,$17,$0
        ret $31,($26),1
        .end minuw
------------------------------------------------------------------------------

This bit:

        mov $31,$2
        cmpbge $2, $3, $2

would be better as:

        cmpbge $31, $3, $2

Bye,
  Rob.

-- 
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com



This archive was generated by hypermail 2a22 : Thu Nov 04 1999 - 16:56:52 PST