Commit 429268fc by Dorit Nuzman Committed by Dorit Nuzman

tree-vect-transform.c (get_initial_def_for_reduction): Set need_epilog_adjust…

tree-vect-transform.c (get_initial_def_for_reduction): Set need_epilog_adjust back to false for MIN/MAX case.

        * tree-vect-transform.c (get_initial_def_for_reduction): Set
        need_epilog_adjust back to false for MIN/MAX case. Set *scalar_def to
        NULL if need_epilog_adjust is false.
        (vect_create_epilog_for_reduction): Variable adjust_in_epilog removed.
        Case 3 always peels first itration, not just for PLUS case, and no need
        to use scalar_initial_def here. Create an epilog adjustment only if
        scalar_initial_def is not NULL.

        (vectorizable_reduction): Remove assert.

From-SVN: r103314
parent b0b0f2b8
2005-08-21 Dorit Nuzman <dorit@il.ibm.com>
* tree-vect-transform.c (get_initial_def_for_reduction): Set
need_epilog_adjust back to false for MIN/MAX case. Set *scalar_def to
NULL if need_epilog_adjust is false.
(vect_create_epilog_for_reduction): Variable adjust_in_epilog removed.
Case 3 always peels first itration, not just for PLUS case, and no need
to use scalar_initial_def here. Create an epilog adjustment only if
scalar_initial_def is not NULL.
(vectorizable_reduction): Remove assert.
2005-08-20 H.J. Lu <hongjiu.lu@intel.com> 2005-08-20 H.J. Lu <hongjiu.lu@intel.com>
PR target/23485 PR target/23485
......
...@@ -751,7 +751,7 @@ get_initial_def_for_reduction (tree stmt, tree init_val, tree *scalar_def) ...@@ -751,7 +751,7 @@ get_initial_def_for_reduction (tree stmt, tree init_val, tree *scalar_def)
case MAX_EXPR: case MAX_EXPR:
def = init_val; def = init_val;
nelements = nunits; nelements = nunits;
need_epilog_adjust = true; need_epilog_adjust = false;
break; break;
default: default:
...@@ -775,13 +775,9 @@ get_initial_def_for_reduction (tree stmt, tree init_val, tree *scalar_def) ...@@ -775,13 +775,9 @@ get_initial_def_for_reduction (tree stmt, tree init_val, tree *scalar_def)
vec = build_constructor_from_list (vectype, t); vec = build_constructor_from_list (vectype, t);
if (!need_epilog_adjust) if (!need_epilog_adjust)
{ *scalar_def = NULL_TREE;
if (INTEGRAL_TYPE_P (type)) else
init_val = build_int_cst (type, 0); *scalar_def = init_val;
else
init_val = build_real (type, dconst0);
}
*scalar_def = init_val;
return vect_init_vector (stmt, vec); return vect_init_vector (stmt, vec);
} }
...@@ -862,7 +858,6 @@ vect_create_epilog_for_reduction (tree vect_def, tree stmt, tree reduction_op, ...@@ -862,7 +858,6 @@ vect_create_epilog_for_reduction (tree vect_def, tree stmt, tree reduction_op,
imm_use_iterator imm_iter; imm_use_iterator imm_iter;
use_operand_p use_p; use_operand_p use_p;
bool extract_scalar_result; bool extract_scalar_result;
bool adjust_in_epilog;
/*** 1. Create the reduction def-use cycle ***/ /*** 1. Create the reduction def-use cycle ***/
...@@ -921,7 +916,6 @@ vect_create_epilog_for_reduction (tree vect_def, tree stmt, tree reduction_op, ...@@ -921,7 +916,6 @@ vect_create_epilog_for_reduction (tree vect_def, tree stmt, tree reduction_op,
bsi_insert_after (&exit_bsi, epilog_stmt, BSI_NEW_STMT); bsi_insert_after (&exit_bsi, epilog_stmt, BSI_NEW_STMT);
extract_scalar_result = true; extract_scalar_result = true;
adjust_in_epilog = true;
} }
else else
{ {
...@@ -997,13 +991,15 @@ vect_create_epilog_for_reduction (tree vect_def, tree stmt, tree reduction_op, ...@@ -997,13 +991,15 @@ vect_create_epilog_for_reduction (tree vect_def, tree stmt, tree reduction_op,
} }
extract_scalar_result = true; extract_scalar_result = true;
adjust_in_epilog = true;
} }
else else
{ {
tree rhs;
/*** Case 3: /*** Case 3:
Create: s = init; Create:
for (offset=0; offset<vector_size; offset+=element_size;) s = extract_field <v_out2, 0>
for (offset=element_size; offset<vector_size; offset+=element_size;)
{ {
Create: s' = extract_field <v_out2, offset> Create: s' = extract_field <v_out2, offset>
Create: s = op <s, s'> Create: s = op <s, s'>
...@@ -1015,33 +1011,19 @@ vect_create_epilog_for_reduction (tree vect_def, tree stmt, tree reduction_op, ...@@ -1015,33 +1011,19 @@ vect_create_epilog_for_reduction (tree vect_def, tree stmt, tree reduction_op,
vec_temp = PHI_RESULT (new_phi); vec_temp = PHI_RESULT (new_phi);
vec_size_in_bits = tree_low_cst (TYPE_SIZE (vectype), 1); vec_size_in_bits = tree_low_cst (TYPE_SIZE (vectype), 1);
/* first iteration is peeled out when possible to minimize rhs = build3 (BIT_FIELD_REF, scalar_type, vec_temp, bitsize,
the number of operations we generate: */ bitsize_zero_node);
if (code == PLUS_EXPR
&& (integer_zerop (scalar_initial_def)
|| real_zerop (scalar_initial_def)))
{
tree rhs = build3 (BIT_FIELD_REF, scalar_type, vec_temp, bitsize,
bitsize_zero_node);
BIT_FIELD_REF_UNSIGNED (rhs) = TYPE_UNSIGNED (scalar_type); BIT_FIELD_REF_UNSIGNED (rhs) = TYPE_UNSIGNED (scalar_type);
epilog_stmt = build2 (MODIFY_EXPR, scalar_type, new_scalar_dest, epilog_stmt = build2 (MODIFY_EXPR, scalar_type, new_scalar_dest,
rhs); rhs);
new_temp = make_ssa_name (new_scalar_dest, epilog_stmt); new_temp = make_ssa_name (new_scalar_dest, epilog_stmt);
TREE_OPERAND (epilog_stmt, 0) = new_temp; TREE_OPERAND (epilog_stmt, 0) = new_temp;
bsi_insert_after (&exit_bsi, epilog_stmt, BSI_NEW_STMT); bsi_insert_after (&exit_bsi, epilog_stmt, BSI_NEW_STMT);
if (vect_print_dump_info (REPORT_DETAILS)) if (vect_print_dump_info (REPORT_DETAILS))
print_generic_expr (vect_dump, epilog_stmt, TDF_SLIM); print_generic_expr (vect_dump, epilog_stmt, TDF_SLIM);
bit_offset = element_bitsize; for (bit_offset = element_bitsize;
}
else
{
new_temp = scalar_initial_def;
bit_offset = 0;
}
for (;
bit_offset < vec_size_in_bits; bit_offset < vec_size_in_bits;
bit_offset += element_bitsize) bit_offset += element_bitsize)
{ {
...@@ -1069,7 +1051,6 @@ vect_create_epilog_for_reduction (tree vect_def, tree stmt, tree reduction_op, ...@@ -1069,7 +1051,6 @@ vect_create_epilog_for_reduction (tree vect_def, tree stmt, tree reduction_op,
} }
extract_scalar_result = false; extract_scalar_result = false;
adjust_in_epilog = false;
} }
} }
...@@ -1110,7 +1091,7 @@ vect_create_epilog_for_reduction (tree vect_def, tree stmt, tree reduction_op, ...@@ -1110,7 +1091,7 @@ vect_create_epilog_for_reduction (tree vect_def, tree stmt, tree reduction_op,
Create: Create:
s_out = scalar_expr <s_out, scalar_initial_def> */ s_out = scalar_expr <s_out, scalar_initial_def> */
if (adjust_in_epilog) if (scalar_initial_def)
{ {
epilog_stmt = build2 (MODIFY_EXPR, scalar_type, new_scalar_dest, epilog_stmt = build2 (MODIFY_EXPR, scalar_type, new_scalar_dest,
build2 (code, scalar_type, new_temp, scalar_initial_def)); build2 (code, scalar_type, new_temp, scalar_initial_def));
...@@ -1291,8 +1272,6 @@ vectorizable_reduction (tree stmt, block_stmt_iterator *bsi, tree *vec_stmt) ...@@ -1291,8 +1272,6 @@ vectorizable_reduction (tree stmt, block_stmt_iterator *bsi, tree *vec_stmt)
/* Prepare the operand that is defined inside the loop body */ /* Prepare the operand that is defined inside the loop body */
loop_vec_def = vect_get_vec_def_for_operand (op0, stmt, NULL); loop_vec_def = vect_get_vec_def_for_operand (op0, stmt, NULL);
gcc_assert (VECTOR_MODE_P (TYPE_MODE (TREE_TYPE (loop_vec_def))));
/* Create the vectorized operation that computes the partial results */ /* Create the vectorized operation that computes the partial results */
*vec_stmt = build2 (MODIFY_EXPR, vectype, vec_dest, *vec_stmt = build2 (MODIFY_EXPR, vectype, vec_dest,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment