aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-vect-generic.c
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2020-03-09 13:23:03 +0100
committerMartin Liska <mliska@suse.cz>2020-06-17 12:04:22 +0200
commit502d63b6d6141597bb18fd23c87736a1b384cf8f (patch)
treeeba6680f649788bfbb44d1ec63183781460c997f /gcc/tree-vect-generic.c
parent2021af0c23acaa827b5a8c5c5ba82b713f9cff1e (diff)
downloadgcc-502d63b6d6141597bb18fd23c87736a1b384cf8f.zip
gcc-502d63b6d6141597bb18fd23c87736a1b384cf8f.tar.gz
gcc-502d63b6d6141597bb18fd23c87736a1b384cf8f.tar.bz2
Lower VEC_COND_EXPR into internal functions.
gcc/ChangeLog: * Makefile.in: Add new file. * expr.c (expand_expr_real_2): Add gcc_unreachable as we should not meet this condition. (do_store_flag): Likewise. * gimplify.c (gimplify_expr): Gimplify first argument of VEC_COND_EXPR to be a SSA name. * internal-fn.c (vec_cond_mask_direct): New. (vec_cond_direct): Likewise. (vec_condu_direct): Likewise. (vec_condeq_direct): Likewise. (expand_vect_cond_optab_fn): New. (expand_vec_cond_optab_fn): Likewise. (expand_vec_condu_optab_fn): Likewise. (expand_vec_condeq_optab_fn): Likewise. (expand_vect_cond_mask_optab_fn): Likewise. (expand_vec_cond_mask_optab_fn): Likewise. (direct_vec_cond_mask_optab_supported_p): Likewise. (direct_vec_cond_optab_supported_p): Likewise. (direct_vec_condu_optab_supported_p): Likewise. (direct_vec_condeq_optab_supported_p): Likewise. * internal-fn.def (VCOND): New OPTAB. (VCONDU): Likewise. (VCONDEQ): Likewise. (VCOND_MASK): Likewise. * optabs.c (get_rtx_code): Make it global. (expand_vec_cond_mask_expr): Removed. (expand_vec_cond_expr): Removed. * optabs.h (expand_vec_cond_expr): Likewise. (vector_compare_rtx): Make it global. * passes.def: Add new pass_gimple_isel pass. * tree-cfg.c (verify_gimple_assign_ternary): Add check for VEC_COND_EXPR about first argument. * tree-pass.h (make_pass_gimple_isel): New. * tree-ssa-forwprop.c (pass_forwprop::execute): Prevent propagation of the first argument of a VEC_COND_EXPR. * tree-ssa-reassoc.c (ovce_extract_ops): Support SSA_NAME as first argument of a VEC_COND_EXPR. (optimize_vec_cond_expr): Likewise. * tree-vect-generic.c (expand_vector_divmod): Make SSA_NAME for a first argument of created VEC_COND_EXPR. (expand_vector_condition): Fix coding style. * tree-vect-stmts.c (vectorizable_condition): Gimplify first argument. * gimple-isel.cc: New file. gcc/testsuite/ChangeLog: * g++.dg/vect/vec-cond-expr-eh.C: New test.
Diffstat (limited to 'gcc/tree-vect-generic.c')
-rw-r--r--gcc/tree-vect-generic.c45
1 files changed, 27 insertions, 18 deletions
diff --git a/gcc/tree-vect-generic.c b/gcc/tree-vect-generic.c
index a7fe83d..fb955bb 100644
--- a/gcc/tree-vect-generic.c
+++ b/gcc/tree-vect-generic.c
@@ -694,12 +694,14 @@ expand_vector_divmod (gimple_stmt_iterator *gsi, tree type, tree op0,
if (addend == NULL_TREE
&& expand_vec_cond_expr_p (type, type, LT_EXPR))
{
- tree zero, cst, cond, mask_type;
- gimple *stmt;
+ tree zero, cst, mask_type, mask;
+ gimple *stmt, *cond;
mask_type = truth_type_for (type);
zero = build_zero_cst (type);
- cond = build2 (LT_EXPR, mask_type, op0, zero);
+ mask = make_ssa_name (mask_type);
+ cond = gimple_build_assign (mask, LT_EXPR, op0, zero);
+ gsi_insert_before (gsi, cond, GSI_SAME_STMT);
tree_vector_builder vec (type, nunits, 1);
for (i = 0; i < nunits; i++)
vec.quick_push (build_int_cst (TREE_TYPE (type),
@@ -707,8 +709,8 @@ expand_vector_divmod (gimple_stmt_iterator *gsi, tree type, tree op0,
<< shifts[i]) - 1));
cst = vec.build ();
addend = make_ssa_name (type);
- stmt = gimple_build_assign (addend, VEC_COND_EXPR, cond,
- cst, zero);
+ stmt
+ = gimple_build_assign (addend, VEC_COND_EXPR, mask, cst, zero);
gsi_insert_before (gsi, stmt, GSI_SAME_STMT);
}
}
@@ -950,21 +952,28 @@ expand_vector_condition (gimple_stmt_iterator *gsi)
tree index = bitsize_int (0);
tree comp_width = width;
tree comp_index = index;
- int i;
location_t loc = gimple_location (gsi_stmt (*gsi));
+ tree_code code = TREE_CODE (a);
- if (!is_gimple_val (a))
+ if (code == SSA_NAME)
{
- gcc_assert (COMPARISON_CLASS_P (a));
- a_is_comparison = true;
- a1 = TREE_OPERAND (a, 0);
- a2 = TREE_OPERAND (a, 1);
- comp_inner_type = TREE_TYPE (TREE_TYPE (a1));
- comp_width = vector_element_bits_tree (TREE_TYPE (a1));
+ gimple *assign = SSA_NAME_DEF_STMT (a);
+ if (TREE_CODE_CLASS (gimple_assign_rhs_code (assign)) == tcc_comparison)
+ {
+ a_is_comparison = true;
+ a1 = gimple_assign_rhs1 (assign);
+ a2 = gimple_assign_rhs2 (assign);
+ code = gimple_assign_rhs_code (assign);
+ comp_inner_type = TREE_TYPE (TREE_TYPE (a1));
+ comp_width = vector_element_bits_tree (TREE_TYPE (a1));
+ }
}
- if (expand_vec_cond_expr_p (type, TREE_TYPE (a1), TREE_CODE (a)))
- return;
+ if (expand_vec_cond_expr_p (type, TREE_TYPE (a1), code))
+ {
+ gcc_assert (TREE_CODE (a) == SSA_NAME || TREE_CODE (a) == VECTOR_CST);
+ return;
+ }
/* Handle vector boolean types with bitmasks. If there is a comparison
and we can expand the comparison into the vector boolean bitmask,
@@ -987,7 +996,7 @@ expand_vector_condition (gimple_stmt_iterator *gsi)
: expand_vec_cmp_expr_p (TREE_TYPE (a1), type, TREE_CODE (a))))
{
if (a_is_comparison)
- a = gimplify_build2 (gsi, TREE_CODE (a), type, a1, a2);
+ a = gimplify_build2 (gsi, code, type, a1, a2);
a1 = gimplify_build2 (gsi, BIT_AND_EXPR, type, a, b);
a2 = gimplify_build1 (gsi, BIT_NOT_EXPR, type, a);
a2 = gimplify_build2 (gsi, BIT_AND_EXPR, type, a2, c);
@@ -1018,7 +1027,7 @@ expand_vector_condition (gimple_stmt_iterator *gsi)
int nunits = nunits_for_known_piecewise_op (type);
vec_alloc (v, nunits);
- for (i = 0; i < nunits; i++)
+ for (int i = 0; i < nunits; i++)
{
tree aa, result;
tree bb = tree_vec_extract (gsi, inner_type, b, width, index);
@@ -1029,7 +1038,7 @@ expand_vector_condition (gimple_stmt_iterator *gsi)
comp_width, comp_index);
tree aa2 = tree_vec_extract (gsi, comp_inner_type, a2,
comp_width, comp_index);
- aa = fold_build2 (TREE_CODE (a), cond_type, aa1, aa2);
+ aa = fold_build2 (code, cond_type, aa1, aa2);
}
else if (a_is_scalar_bitmask)
{