qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v1 4/8] target-ppc: add vabsdu[b, h, w] instruct


From: David Gibson
Subject: Re: [Qemu-devel] [PATCH v1 4/8] target-ppc: add vabsdu[b, h, w] instructions
Date: Fri, 29 Jul 2016 13:46:41 +1000
User-agent: Mutt/1.6.2 (2016-07-01)

On Thu, Jul 28, 2016 at 06:22:05PM +0530, Richard Henderson wrote:
> On 07/28/2016 12:19 PM, Nikunj A Dadhania wrote:
> > +        r->element[i] = abs(a->element[i] - b->element[i]);             \
> > +    }                                                                   \
> > +}
> > +
> > +/* VABSDU - Vector absolute difference unsigned
> > + *   name    - instruction mnemonic suffix (b: byte, h: halfword, w: word)
> > + *   element - element type to access from vector
> > + */
> > +#define VABSDU(type, element)                   \
> > +    VABSDU_DO(absdu##type, element)
> > +VABSDU(b, u8)
> > +VABSDU(h, u16)
> > +VABSDU(w, u32)
> 
> From whence are you receiving this abs definition, and how do you expect it
> to work with an unsigned input?
> 
> I can only imagine you're getting abs(3), aka int abs(int), from stdlib.h.
> Which technically does work post-arithmetic promotion for u8 and u16, but it
> does not for u32.

So, I noticed this and was also concerned, but I more or less
convinced myself that it would still work, by the magic of 2's
complement, as long as sizeof(int) >= 4.

Maybe I'm wrong, though.

> I think we'd prefer an explicit (a > b ? a - b : b - a).

That probably is easier to follow, though.

-- 
David Gibson                    | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
                                | _way_ _around_!
http://www.ozlabs.org/~dgibson

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]