[patch, vectorizer] Add checks that vectype exists
Ira Rosen
IRAR@il.ibm.com
Mon Oct 22 09:51:00 GMT 2007
Hi,
Following Uros's fix to PR tree-optimization/33742
(http://gcc.gnu.org/ml/gcc-patches/2007-10/msg00707.html), checks that
vectype exists should be also added in the analysis of SLP. In
transformation, vectype must not be NULL, so I added gcc_asserts to verify
vectype existence.
Bootstrapped and tested on powerpc-64-linux.
O.K. for mainline?
Thanks,
Ira
ChangeLog:
* tree-vect-analyze.c (vect_build_slp_tree): Return false if
vectype cannot be determined for the scalar type.
(vect_analyze_slp_instance): Likewise.
* tree-vect-transform.c (vect_model_reduction_cost): Add
gcc_assert to verify that vectype exists.
(vect_get_constant_vectors, vect_get_vec_def_for_operand,
get_initial_def_for_reduction, vect_create_epilog_for_reduction,
vectorizable_reduction): Likewise.
Index: tree-vect-analyze.c
===================================================================
--- tree-vect-analyze.c (revision 129521)
+++ tree-vect-analyze.c (working copy)
@@ -2662,6 +2662,16 @@ vect_build_slp_tree (loop_vec_info loop_
scalar_type = TREE_TYPE (GIMPLE_STMT_OPERAND (stmt, 0));
vectype = get_vectype_for_scalar_type (scalar_type);
+ if (!vectype)
+ {
+ if (vect_print_dump_info (REPORT_SLP))
+ {
+ fprintf (vect_dump, "Build SLP failed: unsupported data-type
");
+ print_generic_expr (vect_dump, scalar_type, TDF_SLIM);
+ }
+ return false;
+ }
+
gcc_assert (LOOP_VINFO_VECT_FACTOR (loop_vinfo));
vectorization_factor = LOOP_VINFO_VECT_FACTOR (loop_vinfo);
ncopies = vectorization_factor / TYPE_VECTOR_SUBPARTS (vectype);
@@ -2967,6 +2977,16 @@ vect_analyze_slp_instance (loop_vec_info
/* FORNOW: multiple types are not supported. */
scalar_type = TREE_TYPE (DR_REF (STMT_VINFO_DATA_REF (vinfo_for_stmt
(stmt))));
vectype = get_vectype_for_scalar_type (scalar_type);
+ if (!vectype)
+ {
+ if (vect_print_dump_info (REPORT_SLP))
+ {
+ fprintf (vect_dump, "Build SLP failed: unsupported data-type ");
+ print_generic_expr (vect_dump, scalar_type, TDF_SLIM);
+ }
+ return false;
+ }
+
nunits = TYPE_VECTOR_SUBPARTS (vectype);
vectorization_factor = LOOP_VINFO_VECT_FACTOR (loop_vinfo);
ncopies = vectorization_factor / nunits;
Index: tree-vect-transform.c
===================================================================
--- tree-vect-transform.c (revision 129521)
+++ tree-vect-transform.c (working copy)
@@ -401,6 +401,7 @@ vect_model_reduction_cost (stmt_vec_info
reduction_op = TREE_OPERAND (operation, op_type-1);
vectype = get_vectype_for_scalar_type (TREE_TYPE (reduction_op));
+ gcc_assert (vectype);
mode = TYPE_MODE (vectype);
orig_stmt = STMT_VINFO_RELATED_STMT (stmt_info);
@@ -1349,6 +1350,7 @@ vect_get_constant_vectors (slp_tree slp_
number_of_places_left_in_vector = nunits;
vector_type = get_vectype_for_scalar_type (TREE_TYPE (op));
+ gcc_assert (vector_type);
vec_cst = build_constructor_from_list (vector_type, t);
VEC_quick_push (tree, voprnds,
vect_init_vector (stmt, vec_cst,
vector_type,
@@ -1791,6 +1793,7 @@ vect_get_vec_def_for_operand (tree op, t
t = tree_cons (NULL_TREE, op, t);
}
vector_type = get_vectype_for_scalar_type (TREE_TYPE (op));
+ gcc_assert (vector_type);
vec_cst = build_vector (vector_type, t);
return vect_init_vector (stmt, vec_cst, vector_type, NULL);
@@ -1813,6 +1816,7 @@ vect_get_vec_def_for_operand (tree op, t
/* FIXME: use build_constructor directly. */
vector_type = get_vectype_for_scalar_type (TREE_TYPE (def));
+ gcc_assert (vector_type);
vec_inv = build_constructor_from_list (vector_type, t);
return vect_init_vector (stmt, vec_inv, vector_type, NULL);
}
@@ -2112,6 +2116,7 @@ get_initial_def_for_reduction (tree stmt
for (i = nunits - 1; i >= 0; --i)
t = tree_cons (NULL_TREE, def_for_init, t);
vector_type = get_vectype_for_scalar_type (TREE_TYPE (def_for_init));
+ gcc_assert (vector_type);
init_def = build_vector (vector_type, t);
break;
@@ -2222,6 +2227,7 @@ vect_create_epilog_for_reduction (tree v
op_type = TREE_OPERAND_LENGTH (operation);
reduction_op = TREE_OPERAND (operation, op_type-1);
vectype = get_vectype_for_scalar_type (TREE_TYPE (reduction_op));
+ gcc_assert (vectype);
mode = TYPE_MODE (vectype);
/*** 1. Create the reduction def-use cycle ***/
@@ -2795,6 +2801,7 @@ vectorizable_reduction (tree stmt, block
reduction variable, and get the tree-code from orig_stmt. */
orig_code = TREE_CODE (GIMPLE_STMT_OPERAND (orig_stmt, 1));
vectype = get_vectype_for_scalar_type (TREE_TYPE (def));
+ gcc_assert (vectype);
vec_mode = TYPE_MODE (vectype);
}
else
More information about the Gcc-patches
mailing list