On Mon, Feb 03, 2020 at 05:02:25PM -0500, Michael Meissner wrote:
> On Fri, Jan 31, 2020 at 11:30:22AM -0600, Segher Boessenkool wrote:
> > But why is that the correct thing to do?  Garbage in, garbage out is
> > perfectly fine?  Or do we have (e.g.) builtins that specify this masking?
> > If so, please say that here.
> 
> It has been this way since I added these for power7 or power8, so I'm not
> changing the semantics here.

Please don't cut away too much context.

> +  /* Mask the element to make sure the element number is between 0 and the
> +     maximum number of elements - 1 so that we don't generate an address
> +     outside the vector.  */

But why is that the correct thing to do?  Garbage in, garbage out is
perfectly fine?  Or do we have (e.g.) builtins that specify this masking?
If so, please say that here.

The comment should not just say it is masking thigs; that does not help
the reader much, that isn't too hard to see.  But *why* is it masking
things?  Is that a requirement, is that for better performance, is there
no reason?  If there is no reason, and it could be better not to do this,
a FIXME comment would help.

> Quoting from the LE abi:
> 
> VEC_EXTRACT (ARG1, ARG2)
> 
> This function uses modular arithmetic on ARG2 to determine the element 
> number. For
> example, if ARG2 is out of range, the compiler uses ARG2 modulo the number of 
> elements
> in the vector to determine the element position.

Right.  So it is *not* "so that we don't generate an address outside the
vector" -- it is simply because the API definition says we do, so we
should.


Segher

Reply via email to