From 5e84569c0452c39bf60fbd066801edc1907a982f Mon Sep 17 00:00:00 2001 From: glisse Date: Fri, 3 Oct 2014 19:57:01 +0000 Subject: 2014-10-03 Marc Glisse PR c++/54427 PR c++/57198 PR c++/58845 gcc/c-family/ * c-common.c (warn_logical_operator): Punt for vectors. gcc/cp/ * typeck.c (cp_build_binary_op): save_expr after convert to save redundant operations. [TRUTH_ANDIF_EXPR, TRUTH_ORIF_EXPR]: Handle vectors. (cp_build_unary_op) [TRUTH_NOT_EXPR]: Likewise. gcc/ * doc/extend.texi (Vector Extensions): Document &&, ||, ! in C++. gcc/testsuite/ * g++.dg/ext/vector9.C: Update, not an error anymore. * g++.dg/ext/vector27.C: Replace with new test. * g++.dg/ext/vector28.C: New file. * g++.dg/other/error23.C: Update to a different error. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@215872 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/doc/extend.texi | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'gcc/doc') diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index c78ffb2dabc..de056618226 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -7918,6 +7918,13 @@ vector. If both @code{b} and @code{c} are scalars and the type of @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}. +In C++, the logic operators @code{!, &&, ||} are available for vectors. +@code{!v} is equivalent to @code{v == 0}, @code{a && b} is equivalent to +@code{a!=0 & b!=0} and @code{a || b} is equivalent to @code{a!=0 | b!=0}. +For mixed operations between a scalar @code{s} and a vector @code{v}, +@code{s && v} is equivalent to @code{s?v!=0:0} (the evaluation is +short-circuit) and @code{v && s} is equivalent to @code{v!=0 & (s?-1:0)}. + Vector shuffling is available using functions @code{__builtin_shuffle (vec, mask)} and @code{__builtin_shuffle (vec0, vec1, mask)}. -- cgit v1.2.1