diff options
Diffstat (limited to 'gcc/tree-vect-generic.c')
-rw-r--r-- | gcc/tree-vect-generic.c | 45 |
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) { |