diff options
author | Artjoms Sinkarovs <artyom.shinkaroff@gmail.com> | 2011-09-29 11:29:03 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2011-09-29 11:29:03 +0000 |
commit | d246ab4f578b2e3369963386bafd66b26de8e63d (patch) | |
tree | 288524066a797ac20c1839c796218ffa83932145 /gcc/doc/extend.texi | |
parent | 7c99ecef0b605466c522f4c170811761339dac16 (diff) | |
download | gcc-d246ab4f578b2e3369963386bafd66b26de8e63d.zip gcc-d246ab4f578b2e3369963386bafd66b26de8e63d.tar.gz gcc-d246ab4f578b2e3369963386bafd66b26de8e63d.tar.bz2 |
expr.c (do_store_flag): Expand vector comparison by building an appropriate VEC_COND_EXPR.
2011-09-29 Artjoms Sinkarovs <artyom.shinkaroff@gmail.com>
* expr.c (do_store_flag): Expand vector comparison by
building an appropriate VEC_COND_EXPR.
* c-typeck.c (build_binary_op): Typecheck vector comparisons.
(c_objc_common_truthvalue_conversion): Adjust.
* tree-vect-generic.c (do_compare): Helper function.
(expand_vector_comparison): Check if hardware supports
vector comparison of the given type or expand vector
piecewise.
(expand_vector_operation): Treat comparison as binary
operation of vector type.
(expand_vector_operations_1): Adjust.
* gcc.c-torture/execute/vector-compare-1.c: New testcase.
* gcc.c-torture/execute/vector-compare-2.c: Likewise.
* gcc.dg/vector-compare-1.c: Likewise.
* gcc.dg/vector-compare-2.c: Likewise.
From-SVN: r179342
Diffstat (limited to 'gcc/doc/extend.texi')
-rw-r--r-- | gcc/doc/extend.texi | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index f59333c..e8a777d 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -6561,6 +6561,29 @@ invoke undefined behavior at runtime. Warnings for out of bound accesses for vector subscription can be enabled with @option{-Warray-bounds}. +In GNU C vector comparison is supported within standard comparison +operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be +vector expressions of integer-type or real-type. Comparison between +integer-type vectors and real-type vectors are not supported. The +result of the comparison is a vector of the same width and number of +elements as the comparison operands with a signed integral element +type. + +Vectors are compared element-wise producing 0 when comparison is false +and -1 (constant of the appropriate type where all bits are set) +otherwise. Consider the following example. + +@smallexample +typedef int v4si __attribute__ ((vector_size (16))); + +v4si a = @{1,2,3,4@}; +v4si b = @{3,2,1,4@}; +v4si c; + +c = a > b; /* The result would be @{0, 0,-1, 0@} */ +c = a == b; /* The result would be @{0,-1, 0,-1@} */ +@end smallexample + You can declare variables and use them in function calls and returns, as well as in assignments and some casts. You can specify a vector type as a return type for a function. Vector types can also be used as function |