This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH] Add comparison operators for vector types
- From: Chris Lattner <clattner at apple dot com>
- To: Andrew Pinski <Andrew_Pinski at playstation dot sony dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, Trevor_Smigiel <Trevor_Smigiel at playstation dot sony dot com>
- Date: Wed, 3 Jun 2009 17:48:58 -0700
- Subject: Re: [PATCH] Add comparison operators for vector types
- References: <firstname.lastname@example.org> <69D42E97-CB30-4F67-985A-1270877FDF3D@apple.com> <email@example.com>
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
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
Note that OpenCL defines vector comparisons differently than
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))
if (vec_all(x > y))
if ((x > y))
(assuming that GCC eventually allows vector element access through
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
An over-simplified view is that OpenCL = C + vectors + address
spaces. The language spec is available on the OpenCL standards page.