This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Add comparison operators for vector types


On Jun 2, 2009, at 4:27 PM, Andrew Pinski wrote:
Is this something you want to do on the Cell alone, or for generic vectors
in general?

generic vectors in general.

Ok, I don't know who makes decisions like this for GCC, but it seems worthwhile to consider whether this is the right default behavior for generic vectors. OpenCL is a *cross platform* industry standard, so following it seems pretty reasonable, and this is what Clang does (for example).


 Note that OpenCL defines vector comparisons differently than
this.

What does that language define them?

A comparison of two vectors returns a vector with the same number of elements, where each element is set to -1 or 0 if the per-element comparison is true or false. This follows in line with the rest of the vector operations operating element-at-a-time, and makes it easy to do things like:


 if (vec_any(x < y))
and:
  if (vec_all(x > y))
and:
  if ((x > y)[2])

(assuming that GCC eventually allows vector element access through generic vectors).

This is also extremely useful for "vector select" idioms.

 If GCC aims to support it one day, it would useful to consider what
it wants.  Cell is a particularly useful target for OpenCL.

But isn't OpenCL a different language than C, or is it extensions to C/C++?

An over-simplified view is that OpenCL = C + vectors + address spaces. The language spec is available on the OpenCL standards page.


-Chris


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]