From: Marc Glisse Date: Fri, 31 Jan 2014 12:59:44 +0000 (+0100) Subject: extend.texi (Vector Extensions): Document ?: in C++. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0878d68a0b6e1bc0d89be4cb738e4ee34f004a6c;p=gcc.git extend.texi (Vector Extensions): Document ?: in C++. 2014-01-31 Marc Glisse gcc/ * doc/extend.texi (Vector Extensions): Document ?: in C++. From-SVN: r207340 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index bbf6b476f97..db13a3e77ca 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2014-01-31 Marc Glisse + + * doc/extend.texi (Vector Extensions): Document ?: in C++. + 2014-01-31 Richard Biener PR middle-end/59990 diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 2f4f91d233a..ee98b2c09be 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -7233,6 +7233,19 @@ c = a > b; /* The result would be @{0, 0,-1, 0@} */ c = a == b; /* The result would be @{0,-1, 0,-1@} */ @end smallexample +In C++, the ternary operator @code{?:} is available. @code{a?b:c}, where +@code{b} and @code{c} are vectors of the same type and @code{a} is an +integer vector with the same number of elements of the same size as @code{b} +and @code{c}, computes all three arguments and creates a vector +@code{@{a[0]?b[0]:c[0], a[1]?b[1]:c[1], @dots{}@}}. Note that unlike in +OpenCL, @code{a} is thus interpreted as @code{a != 0} and not @code{a < 0}. +As in the case of binary operations, this syntax is also accepted when +one of @code{b} or @code{c} is a scalar that is then transformed into a +vector. If both @code{b} and @code{c} are scalars and the type of +@code{true?b:c} has the same size as the element type of @code{a}, then +@code{b} and @code{c} are converted to a vector type whose elements have +this type and with the same number of elements as @code{a}. + Vector shuffling is available using functions @code{__builtin_shuffle (vec, mask)} and @code{__builtin_shuffle (vec0, vec1, mask)}.