On Fri, 12 Apr 2013, Richard Biener wrote:

On Fri, Apr 12, 2013 at 11:03 AM, Marc Glisse <marc.gli...@inria.fr> wrote:
Hello,

this adds support for vector !, && and ||. In the long run, I think it would
be good to be able to use TRUTH_*_EXPR with vectors, but that's probably a
lot of work.

It currently restricts && and || to vector-vector operations. I'd like to
also support mixed scalar-vector later, but it is a bit more complicated.
With vectors, && evaluates both sides.

Exactly for this reason I think supporting logical operations is ill-defined
for vectors.

First, as a remark, in C++, && and || can be overloaded by the user, and in that case they are not short-circuit, so doing this for vectors wouldn't really be anything new. OpenCL also defines && and || for vectors.

The way we define "boolean" vectors allows to simply
use bit operations here - so what issue do you want to address?  The
automatic X-to-bool decay?  Thus, avoid the need to write v1 != 0 | v2 != 0?

My goal would be for people to share the code between the scalar and vector versions, that code written for scalars would start just working with vectors. Since people use !, && and || for scalars and not ~, & and |, that means supporting those.

(there would still always be traps, like the fact that the equivalent of "true" for vectors is -1, or that && is not short-circuit, but most code would be fine)

--
Marc Glisse

Reply via email to