Hi!

On Fri, Sep 25, 2020 at 09:07:46AM -0500, Paul A. Clarke wrote:
> On Thu, Sep 24, 2020 at 06:22:10PM -0500, Segher Boessenkool wrote:
> > > +  result [(__N & 0b1111)] = __D;
> > 
> > Hrm, GCC supports binary constants like this since 2007, so okay.  But I
> > have to wonder if this improves anything over hex (or decimal even!)
> > The parens are superfluous (and only hinder legibility), fwiw.

> > > +  result [(__N & 0b1)] = __D;
> > 
> > Especially single-digit numbers look really goofy (like 0x0, but even
> > worse for binary somehow).
> > 
> > Anyway, okay for trunk, with or without those things improved.  Thanks!
> 
> I was trying to obviously and consistently convey the sizes of the masks,
> but I really want to convey _why_ there are masks, so let me try a
> different approach, below.

> +extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, 
> __artificial__))
> +_mm_insert_epi8 (__m128i const __A, int const __D, int const __N)
> +{
> +  __v16qi result = (__v16qi)__A;
> +
> +  result [__N % (sizeof result / sizeof result[0])] = __D;
> +
> +  return (__m128i) result;
> +}

I don't think this helps explain things, sorry.  Just add a comment
if you want to explain things?  Simpler and works perfectly always.

To read these files I always open the x86 ISA docs anyway; I think
everyone will have to anyway, so you do not have to explain all details
you emulate, only the very tricky ones, or implementation choices, that
kind of thing.


Segher

Reply via email to