tree-vect-loop-manip.c (vect_create_cond_for_alias_checks): Remove cond_expr_stmt_list argument and do not gimplify the built expression.

2013-03-18  Richard Biener  <rguenther@suse.de>

	* tree-vect-loop-manip.c (vect_create_cond_for_alias_checks):
	Remove cond_expr_stmt_list argument and do not gimplify the
	built expression.
	(vect_loop_versioning): Adjust.
	* tree-vect-data-refs.c (vect_create_addr_base_for_vector_ref):
	Cleanup to use less temporaries.
	(vect_create_data_ref_ptr): Cleanup.

From-SVN: r196782
This commit is contained in:
Richard Biener 2013-03-18 13:57:33 +00:00 committed by Richard Biener
parent 38c56a5b21
commit 4bdd44c4bc
3 changed files with 53 additions and 82 deletions

View File

@ -1,3 +1,13 @@
2013-03-18 Richard Biener <rguenther@suse.de>
* tree-vect-loop-manip.c (vect_create_cond_for_alias_checks):
Remove cond_expr_stmt_list argument and do not gimplify the
built expression.
(vect_loop_versioning): Adjust.
* tree-vect-data-refs.c (vect_create_addr_base_for_vector_ref):
Cleanup to use less temporaries.
(vect_create_data_ref_ptr): Cleanup.
2013-03-18 Jakub Jelinek <jakub@redhat.com> 2013-03-18 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/56635 PR tree-optimization/56635

View File

@ -3470,19 +3470,16 @@ vect_create_addr_base_for_vector_ref (gimple stmt,
{ {
stmt_vec_info stmt_info = vinfo_for_stmt (stmt); stmt_vec_info stmt_info = vinfo_for_stmt (stmt);
struct data_reference *dr = STMT_VINFO_DATA_REF (stmt_info); struct data_reference *dr = STMT_VINFO_DATA_REF (stmt_info);
tree data_ref_base = unshare_expr (DR_BASE_ADDRESS (dr)); tree data_ref_base;
const char *base_name; const char *base_name;
tree data_ref_base_var; tree addr_base;
tree vec_stmt;
tree addr_base, addr_expr;
tree dest; tree dest;
gimple_seq seq = NULL; gimple_seq seq = NULL;
tree base_offset = unshare_expr (DR_OFFSET (dr)); tree base_offset;
tree init = unshare_expr (DR_INIT (dr)); tree init;
tree vect_ptr_type; tree vect_ptr_type;
tree step = TYPE_SIZE_UNIT (TREE_TYPE (DR_REF (dr))); tree step = TYPE_SIZE_UNIT (TREE_TYPE (DR_REF (dr)));
loop_vec_info loop_vinfo = STMT_VINFO_LOOP_VINFO (stmt_info); loop_vec_info loop_vinfo = STMT_VINFO_LOOP_VINFO (stmt_info);
tree base;
if (loop_vinfo && loop && loop != (gimple_bb (stmt))->loop_father) if (loop_vinfo && loop && loop != (gimple_bb (stmt))->loop_father)
{ {
@ -3494,6 +3491,12 @@ vect_create_addr_base_for_vector_ref (gimple stmt,
base_offset = unshare_expr (STMT_VINFO_DR_OFFSET (stmt_info)); base_offset = unshare_expr (STMT_VINFO_DR_OFFSET (stmt_info));
init = unshare_expr (STMT_VINFO_DR_INIT (stmt_info)); init = unshare_expr (STMT_VINFO_DR_INIT (stmt_info));
} }
else
{
data_ref_base = unshare_expr (DR_BASE_ADDRESS (dr));
base_offset = unshare_expr (DR_OFFSET (dr));
init = unshare_expr (DR_INIT (dr));
}
if (loop_vinfo) if (loop_vinfo)
base_name = get_name (data_ref_base); base_name = get_name (data_ref_base);
@ -3504,29 +3507,17 @@ vect_create_addr_base_for_vector_ref (gimple stmt,
base_name = get_name (DR_REF (dr)); base_name = get_name (DR_REF (dr));
} }
data_ref_base_var = create_tmp_var (TREE_TYPE (data_ref_base), "batmp");
data_ref_base = force_gimple_operand (data_ref_base, &seq, true,
data_ref_base_var);
gimple_seq_add_seq (new_stmt_list, seq);
/* Create base_offset */ /* Create base_offset */
base_offset = size_binop (PLUS_EXPR, base_offset = size_binop (PLUS_EXPR,
fold_convert (sizetype, base_offset), fold_convert (sizetype, base_offset),
fold_convert (sizetype, init)); fold_convert (sizetype, init));
dest = create_tmp_var (sizetype, "base_off");
base_offset = force_gimple_operand (base_offset, &seq, true, dest);
gimple_seq_add_seq (new_stmt_list, seq);
if (offset) if (offset)
{ {
tree tmp = create_tmp_var (sizetype, "offset");
offset = fold_build2 (MULT_EXPR, sizetype, offset = fold_build2 (MULT_EXPR, sizetype,
fold_convert (sizetype, offset), step); fold_convert (sizetype, offset), step);
base_offset = fold_build2 (PLUS_EXPR, sizetype, base_offset = fold_build2 (PLUS_EXPR, sizetype,
base_offset, offset); base_offset, offset);
base_offset = force_gimple_operand (base_offset, &seq, false, tmp);
gimple_seq_add_seq (new_stmt_list, seq);
} }
/* base + base_offset */ /* base + base_offset */
@ -3540,34 +3531,26 @@ vect_create_addr_base_for_vector_ref (gimple stmt,
} }
vect_ptr_type = build_pointer_type (STMT_VINFO_VECTYPE (stmt_info)); vect_ptr_type = build_pointer_type (STMT_VINFO_VECTYPE (stmt_info));
base = get_base_address (DR_REF (dr)); addr_base = fold_convert (vect_ptr_type, addr_base);
if (base dest = vect_get_new_vect_var (vect_ptr_type, vect_pointer_var, base_name);
&& TREE_CODE (base) == MEM_REF) addr_base = force_gimple_operand (addr_base, &seq, false, dest);
vect_ptr_type
= build_qualified_type (vect_ptr_type,
TYPE_QUALS (TREE_TYPE (TREE_OPERAND (base, 0))));
vec_stmt = fold_convert (vect_ptr_type, addr_base);
addr_expr = vect_get_new_vect_var (vect_ptr_type, vect_pointer_var,
base_name);
vec_stmt = force_gimple_operand (vec_stmt, &seq, false, addr_expr);
gimple_seq_add_seq (new_stmt_list, seq); gimple_seq_add_seq (new_stmt_list, seq);
if (DR_PTR_INFO (dr) if (DR_PTR_INFO (dr)
&& TREE_CODE (vec_stmt) == SSA_NAME) && TREE_CODE (addr_base) == SSA_NAME)
{ {
duplicate_ssa_name_ptr_info (vec_stmt, DR_PTR_INFO (dr)); duplicate_ssa_name_ptr_info (addr_base, DR_PTR_INFO (dr));
if (offset) if (offset)
mark_ptr_info_alignment_unknown (SSA_NAME_PTR_INFO (vec_stmt)); mark_ptr_info_alignment_unknown (SSA_NAME_PTR_INFO (addr_base));
} }
if (dump_enabled_p ()) if (dump_enabled_p ())
{ {
dump_printf_loc (MSG_NOTE, vect_location, "created "); dump_printf_loc (MSG_NOTE, vect_location, "created ");
dump_generic_expr (MSG_NOTE, TDF_SLIM, vec_stmt); dump_generic_expr (MSG_NOTE, TDF_SLIM, addr_base);
} }
return vec_stmt; return addr_base;
} }
@ -3647,7 +3630,6 @@ vect_create_data_ref_ptr (gimple stmt, tree aggr_type, struct loop *at_loop,
gimple incr; gimple incr;
tree step; tree step;
bb_vec_info bb_vinfo = STMT_VINFO_BB_VINFO (stmt_info); bb_vec_info bb_vinfo = STMT_VINFO_BB_VINFO (stmt_info);
tree base;
gcc_assert (TREE_CODE (aggr_type) == ARRAY_TYPE gcc_assert (TREE_CODE (aggr_type) == ARRAY_TYPE
|| TREE_CODE (aggr_type) == VECTOR_TYPE); || TREE_CODE (aggr_type) == VECTOR_TYPE);
@ -3699,53 +3681,37 @@ vect_create_data_ref_ptr (gimple stmt, tree aggr_type, struct loop *at_loop,
dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_BASE_OBJECT (dr)); dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_BASE_OBJECT (dr));
} }
/* (1) Create the new aggregate-pointer variable. */ /* (1) Create the new aggregate-pointer variable.
aggr_ptr_type = build_pointer_type (aggr_type); Vector and array types inherit the alias set of their component
base = get_base_address (DR_REF (dr));
if (base
&& TREE_CODE (base) == MEM_REF)
aggr_ptr_type
= build_qualified_type (aggr_ptr_type,
TYPE_QUALS (TREE_TYPE (TREE_OPERAND (base, 0))));
aggr_ptr = vect_get_new_vect_var (aggr_ptr_type, vect_pointer_var, base_name);
/* Vector and array types inherit the alias set of their component
type by default so we need to use a ref-all pointer if the data type by default so we need to use a ref-all pointer if the data
reference does not conflict with the created aggregated data reference does not conflict with the created aggregated data
reference because it is not addressable. */ reference because it is not addressable. */
if (!alias_sets_conflict_p (get_deref_alias_set (aggr_ptr), bool need_ref_all = false;
if (!alias_sets_conflict_p (get_alias_set (aggr_type),
get_alias_set (DR_REF (dr)))) get_alias_set (DR_REF (dr))))
{ need_ref_all = true;
aggr_ptr_type
= build_pointer_type_for_mode (aggr_type,
TYPE_MODE (aggr_ptr_type), true);
aggr_ptr = vect_get_new_vect_var (aggr_ptr_type, vect_pointer_var,
base_name);
}
/* Likewise for any of the data references in the stmt group. */ /* Likewise for any of the data references in the stmt group. */
else if (STMT_VINFO_GROUP_SIZE (stmt_info) > 1) else if (STMT_VINFO_GROUP_SIZE (stmt_info) > 1)
{ {
gimple orig_stmt = STMT_VINFO_GROUP_FIRST_ELEMENT (stmt_info); gimple orig_stmt = STMT_VINFO_GROUP_FIRST_ELEMENT (stmt_info);
do do
{ {
tree lhs = gimple_assign_lhs (orig_stmt); stmt_vec_info sinfo = vinfo_for_stmt (orig_stmt);
if (!alias_sets_conflict_p (get_deref_alias_set (aggr_ptr), struct data_reference *sdr = STMT_VINFO_DATA_REF (sinfo);
get_alias_set (lhs))) if (!alias_sets_conflict_p (get_alias_set (aggr_type),
get_alias_set (DR_REF (sdr))))
{ {
aggr_ptr_type need_ref_all = true;
= build_pointer_type_for_mode (aggr_type,
TYPE_MODE (aggr_ptr_type), true);
aggr_ptr
= vect_get_new_vect_var (aggr_ptr_type, vect_pointer_var,
base_name);
break; break;
} }
orig_stmt = STMT_VINFO_GROUP_NEXT_ELEMENT (sinfo);
orig_stmt = STMT_VINFO_GROUP_NEXT_ELEMENT (vinfo_for_stmt (orig_stmt));
} }
while (orig_stmt); while (orig_stmt);
} }
aggr_ptr_type = build_pointer_type_for_mode (aggr_type, ptr_mode,
need_ref_all);
aggr_ptr = vect_get_new_vect_var (aggr_ptr_type, vect_pointer_var, base_name);
/* Note: If the dataref is in an inner-loop nested in LOOP, and we are /* Note: If the dataref is in an inner-loop nested in LOOP, and we are
vectorizing LOOP (i.e., outer-loop vectorization), we need to create two vectorizing LOOP (i.e., outer-loop vectorization), we need to create two

View File

@ -2271,20 +2271,14 @@ vect_vfa_segment_size (struct data_reference *dr, tree length_factor)
Output: Output:
COND_EXPR - conditional expression. COND_EXPR - conditional expression.
COND_EXPR_STMT_LIST - statements needed to construct the conditional
expression.
The returned value is the conditional expression to be used in the if The returned value is the conditional expression to be used in the if
statement that controls which version of the loop gets executed at runtime. statement that controls which version of the loop gets executed at runtime.
*/ */
static void static void
vect_create_cond_for_alias_checks (loop_vec_info loop_vinfo, vect_create_cond_for_alias_checks (loop_vec_info loop_vinfo, tree * cond_expr)
tree * cond_expr,
gimple_seq * cond_expr_stmt_list)
{ {
struct loop *loop = LOOP_VINFO_LOOP (loop_vinfo);
vec<ddr_p> may_alias_ddrs = vec<ddr_p> may_alias_ddrs =
LOOP_VINFO_MAY_ALIAS_DDRS (loop_vinfo); LOOP_VINFO_MAY_ALIAS_DDRS (loop_vinfo);
int vect_factor = LOOP_VINFO_VECT_FACTOR (loop_vinfo); int vect_factor = LOOP_VINFO_VECT_FACTOR (loop_vinfo);
@ -2333,12 +2327,14 @@ vect_create_cond_for_alias_checks (loop_vec_info loop_vinfo,
dr_b = STMT_VINFO_DATA_REF (vinfo_for_stmt (stmt_b)); dr_b = STMT_VINFO_DATA_REF (vinfo_for_stmt (stmt_b));
} }
addr_base_a = addr_base_a
vect_create_addr_base_for_vector_ref (stmt_a, cond_expr_stmt_list, = fold_build_pointer_plus (DR_BASE_ADDRESS (dr_a),
NULL_TREE, loop); size_binop (PLUS_EXPR, DR_OFFSET (dr_a),
addr_base_b = DR_INIT (dr_a)));
vect_create_addr_base_for_vector_ref (stmt_b, cond_expr_stmt_list, addr_base_b
NULL_TREE, loop); = fold_build_pointer_plus (DR_BASE_ADDRESS (dr_b),
size_binop (PLUS_EXPR, DR_OFFSET (dr_b),
DR_INIT (dr_b)));
if (!operand_equal_p (DR_STEP (dr_a), DR_STEP (dr_b), 0)) if (!operand_equal_p (DR_STEP (dr_a), DR_STEP (dr_b), 0))
length_factor = scalar_loop_iters; length_factor = scalar_loop_iters;
@ -2435,8 +2431,7 @@ vect_loop_versioning (loop_vec_info loop_vinfo,
&cond_expr_stmt_list); &cond_expr_stmt_list);
if (LOOP_REQUIRES_VERSIONING_FOR_ALIAS (loop_vinfo)) if (LOOP_REQUIRES_VERSIONING_FOR_ALIAS (loop_vinfo))
vect_create_cond_for_alias_checks (loop_vinfo, &cond_expr, vect_create_cond_for_alias_checks (loop_vinfo, &cond_expr);
&cond_expr_stmt_list);
cond_expr = force_gimple_operand_1 (cond_expr, &gimplify_stmt_list, cond_expr = force_gimple_operand_1 (cond_expr, &gimplify_stmt_list,
is_gimple_condexpr, NULL_TREE); is_gimple_condexpr, NULL_TREE);