diff options
author | Ilya Enkovich <enkovich.gnu@gmail.com> | 2015-10-21 16:01:43 +0000 |
---|---|---|
committer | Ilya Enkovich <ienkovich@gcc.gnu.org> | 2015-10-21 16:01:43 +0000 |
commit | 9f47c7e5cf3f69d34ad09c97a729649d18dfb3a6 (patch) | |
tree | c0078faec62f54a6b5b518102c489b0e7cd1f459 /gcc/cp | |
parent | 6f9045f4e16df8791ae67e0508b61accc4c982c2 (diff) | |
download | gcc-9f47c7e5cf3f69d34ad09c97a729649d18dfb3a6.zip gcc-9f47c7e5cf3f69d34ad09c97a729649d18dfb3a6.tar.gz gcc-9f47c7e5cf3f69d34ad09c97a729649d18dfb3a6.tar.bz2 |
tm.texi: Regenerated.
gcc/
* doc/tm.texi: Regenerated.
* doc/tm.texi.in (TARGET_VECTORIZE_GET_MASK_MODE): New.
* stor-layout.c (layout_type): Use mode to get vector mask size.
* target.def (get_mask_mode): New.
* targhooks.c (default_get_mask_mode): New.
* targhooks.h (default_get_mask_mode): New.
* gcc/tree-vect-stmts.c (get_same_sized_vectype): Add special case
for boolean vector.
* tree.c (MAX_BOOL_CACHED_PREC): New.
(nonstandard_boolean_type_cache): New.
(build_nonstandard_boolean_type): New.
(make_vector_type): Vector mask has no canonical type.
(build_truth_vector_type): New.
(build_same_sized_truth_vector_type): New.
(truth_type_for): Support vector masks.
* tree.h (VECTOR_BOOLEAN_TYPE_P): New.
(build_truth_vector_type): New.
(build_same_sized_truth_vector_type): New.
(build_nonstandard_boolean_type): New.
* tree-cfg.c (verify_gimple_comparison) Require boolean
vector type for vector comparison.
(verify_gimple_assign_ternary): Likewise.
* optabs.c (expand_vec_cond_expr): Accept boolean vector as
condition operand.
* tree-vect-stmts.c (vectorizable_condition): Use boolean
vector type for vector comparison.
* tree-vect-generic.c (elem_op_func): Add new operand to hold
vector type.
(do_unop): Adjust to modified function type.
(do_binop): Likewise.
(do_plus_minus): Likewise.
(do_negate); Likewise.
(expand_vector_piecewise): Likewise.
(do_cond): Likewise.
(do_compare): Use comparison instead of condition.
(expand_vector_divmod): Use boolean vector type for comparison.
(expand_vector_operations_1): Skip scalar mask operations.
gcc/c
* c-typeck.c (build_conditional_expr): Use boolean vector
type for vector comparison.
(build_vec_cmp): New.
(build_binary_op): Use build_vec_cmp for comparison.
gcc/cp
* call.c (build_conditional_expr_1): Use boolean vector
type for vector comparison.
* typeck.c (build_vec_cmp): New.
(cp_build_binary_op): Use build_vec_cmp for comparison.
gcc/testsuite/
* g++.dg/ext/vector22.C: Allow VEC_COND_EXPR.
From-SVN: r229128
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/call.c | 15 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 16 |
3 files changed, 35 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 9f282d8..2a9e873 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2015-10-21 Ilya Enkovich <enkovich.gnu@gmail.com> + + * call.c (build_conditional_expr_1): Use boolean vector + type for vector comparison. + * typeck.c (build_vec_cmp): New. + (cp_build_binary_op): Use build_vec_cmp for comparison. + 2015-10-20 Jason Merrill <jason@redhat.com> PR c++/66583 diff --git a/gcc/cp/call.c b/gcc/cp/call.c index f8db2df..55b3c8c 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -4627,6 +4627,15 @@ build_conditional_expr_1 (location_t loc, tree arg1, tree arg2, tree arg3, if (VECTOR_INTEGER_TYPE_P (TREE_TYPE (arg1))) { + /* If arg1 is another cond_expr choosing between -1 and 0, + then we can use its comparison. It may help to avoid + additional comparison, produce more accurate diagnostics + and enables folding. */ + if (TREE_CODE (arg1) == VEC_COND_EXPR + && integer_minus_onep (TREE_OPERAND (arg1, 1)) + && integer_zerop (TREE_OPERAND (arg1, 2))) + arg1 = TREE_OPERAND (arg1, 0); + arg1 = force_rvalue (arg1, complain); arg2 = force_rvalue (arg2, complain); arg3 = force_rvalue (arg3, complain); @@ -4739,8 +4748,10 @@ build_conditional_expr_1 (location_t loc, tree arg1, tree arg2, tree arg3, } if (!COMPARISON_CLASS_P (arg1)) - arg1 = cp_build_binary_op (loc, NE_EXPR, arg1, - build_zero_cst (arg1_type), complain); + { + tree cmp_type = build_same_sized_truth_vector_type (arg1_type); + arg1 = build2 (NE_EXPR, cmp_type, arg1, build_zero_cst (arg1_type)); + } return fold_build3 (VEC_COND_EXPR, arg2_type, arg1, arg2, arg3); } diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 9e6f949..3147609 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -3916,6 +3916,20 @@ build_binary_op (location_t location, enum tree_code code, tree op0, tree op1, return cp_build_binary_op (location, code, op0, op1, tf_warning_or_error); } +/* Build a vector comparison of ARG0 and ARG1 using CODE opcode + into a value of TYPE type. Comparison is done via VEC_COND_EXPR. */ + +static tree +build_vec_cmp (tree_code code, tree type, + tree arg0, tree arg1) +{ + tree zero_vec = build_zero_cst (type); + tree minus_one_vec = build_minus_one_cst (type); + tree cmp_type = build_same_sized_truth_vector_type(type); + tree cmp = build2 (code, cmp_type, arg0, arg1); + cmp = fold_if_not_in_template (cmp); + return build3 (VEC_COND_EXPR, type, cmp, minus_one_vec, zero_vec); +} /* Build a binary-operation expression without default conversions. CODE is the kind of expression to build. @@ -4785,7 +4799,7 @@ cp_build_binary_op (location_t location, result_type = build_opaque_vector_type (intt, TYPE_VECTOR_SUBPARTS (type0)); converted = 1; - break; + return build_vec_cmp (resultcode, result_type, op0, op1); } build_type = boolean_type_node; if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE |