On Tue, Sep 6, 2011 at 4:50 PM, Artem Shinkarov
<[email protected]> wrote:
> Here is a new version of the patch which considers the changes from
> 2011-09-02 Richard Guenther
>
>
> ChangeLog
>
> 20011-09-06 Artjoms Sinkarovs <[email protected]>
>
> gcc/
> * fold-const.c (constant_boolean_node): Adjust the meaning
> of boolean for vector types: true = {-1,..}, false = {0,..}.
> (fold_unary_loc): Avoid conversion of vector comparison to
> boolean type.
Both changes have already been done.
> * expr.c (expand_expr_real_2): Expand vector comparison by
> building an appropriate VEC_COND_EXPR.
I prefer
Index: gcc/expr.c
===================================================================
*** gcc/expr.c.orig 2011-08-29 11:48:23.000000000 +0200
--- gcc/expr.c 2011-08-29 12:58:59.000000000 +0200
*************** do_store_flag (sepops ops, rtx target, e
*** 10309,10314 ****
--- 10309,10325 ----
STRIP_NOPS (arg0);
STRIP_NOPS (arg1);
+ /* For vector typed comparisons emit code to generate the desired
+ all-ones or all-zeros mask. Conveniently use the VEC_COND_EXPR
+ expander for this. */
+ if (TREE_CODE (ops->type) == VECTOR_TYPE)
+ {
+ tree ifexp = build2 (ops->code, ops->type, arg0, arg1);
+ tree if_true = constant_boolean_node (true, ops->type);
+ tree if_false = constant_boolean_node (false, ops->type);
+ return expand_vec_cond_expr (ops->type, ifexp, if_true,
if_false, target);
+ }
+
/* Get the rtx comparison code to use. We know that EXP is a comparison
as I said multiple times.
> * 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.
> * tree-cfg.c (verify_gimple_comparison): Adjust.
The tree-cfg.c change has already been done.
Richard.
>
> gcc/config/i386
> * i386.c (ix86_expand_sse_movcc): Consider a case when
> vcond operators are {-1,..} and {0,..}.
>
> gcc/doc
> * extend.texi: Adjust.
>
> gcc/testsuite
> * gcc.c-torture/execute/vector-compare-1.c: New test.
> * gcc.c-torture/execute/vector-compare-2.c: New test.
> * gcc.dg/vector-compare-1.c: New test.
> * gcc.dg/vector-compare-2.c: New test.
>
> bootstrapped and tested on x86_64-unknown-linux-gnu.
>
>
> Thanks,
> Artem.
>