aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorDorit Nuzman <dorit@il.ibm.com>2007-01-16 08:26:03 +0000
committerDorit Nuzman <dorit@gcc.gnu.org>2007-01-16 08:26:03 +0000
commit878aa8171752ad29ae47099e31fbe3df1dcf3133 (patch)
tree7eb41b628f9d5b93cf6e2d18085f834a813d19e6 /gcc
parent03b1d1341cd8640cf83eeadba4c0616cbb916211 (diff)
downloadgcc-878aa8171752ad29ae47099e31fbe3df1dcf3133.zip
gcc-878aa8171752ad29ae47099e31fbe3df1dcf3133.tar.gz
gcc-878aa8171752ad29ae47099e31fbe3df1dcf3133.tar.bz2
tree-vectorizer.h (is_pattern_stmt_p): New.
* tree-vectorizer.h (is_pattern_stmt_p): New. * tree-vect-analyze.c (vect_determine_vectorization_factor): Fix formatting (tabs instead of spaces). Cleanup and clarify setting of STMT_VINFO_VECTYPE. Call is_pattern_stmt_p. * tree-vect-transform.c (vect_get_vec_def_for_operand): Fix typo. (vectorizable_type_demotion): Check that types are integral. (vectorizable_type_promotion): Likewise. (vectorizable_store): Fix typo. Eliminate new-line at end of comments. Co-Authored-By: Tehila Meyzels <tehila@il.ibm.com> From-SVN: r120825
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog13
-rw-r--r--gcc/tree-vect-analyze.c101
-rw-r--r--gcc/tree-vect-transform.c23
-rw-r--r--gcc/tree-vectorizer.h15
4 files changed, 100 insertions, 52 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 7c3b628..45029c3 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,16 @@
+2007-01-16 Dorit Nuzman <dorit@il.ibm.com>
+ Tehila Meyzels <tehila@il.ibm.com>
+
+ * tree-vectorizer.h (is_pattern_stmt_p): New.
+ * tree-vect-analyze.c (vect_determine_vectorization_factor): Fix
+ formatting (tabs instead of spaces). Cleanup and clarify setting
+ of STMT_VINFO_VECTYPE. Call is_pattern_stmt_p.
+ * tree-vect-transform.c (vect_get_vec_def_for_operand): Fix typo.
+ (vectorizable_type_demotion): Check that types are integral.
+ (vectorizable_type_promotion): Likewise.
+ (vectorizable_store): Fix typo. Eliminate new-line at end of
+ comments.
+
2007-01-16 Jan Hubicka <jh@suse.cz>
* tree-ssanames.c (release_dead_ssa_names): Remove invalidated
diff --git a/gcc/tree-vect-analyze.c b/gcc/tree-vect-analyze.c
index 83293d6..114f823 100644
--- a/gcc/tree-vect-analyze.c
+++ b/gcc/tree-vect-analyze.c
@@ -109,52 +109,67 @@ vect_determine_vectorization_factor (loop_vec_info loop_vinfo)
for (si = bsi_start (bb); !bsi_end_p (si); bsi_next (&si))
{
- tree stmt = bsi_stmt (si);
- unsigned int nunits;
- stmt_vec_info stmt_info = vinfo_for_stmt (stmt);
- tree vectype;
+ tree stmt = bsi_stmt (si);
+ unsigned int nunits;
+ stmt_vec_info stmt_info = vinfo_for_stmt (stmt);
+ tree vectype;
- if (vect_print_dump_info (REPORT_DETAILS))
- {
- fprintf (vect_dump, "==> examining statement: ");
- print_generic_expr (vect_dump, stmt, TDF_SLIM);
- }
+ if (vect_print_dump_info (REPORT_DETAILS))
+ {
+ fprintf (vect_dump, "==> examining statement: ");
+ print_generic_expr (vect_dump, stmt, TDF_SLIM);
+ }
+
+ if (TREE_CODE (stmt) != GIMPLE_MODIFY_STMT)
+ continue;
+
+ gcc_assert (stmt_info);
- gcc_assert (stmt_info);
- /* skip stmts which do not need to be vectorized. */
- if (!STMT_VINFO_RELEVANT_P (stmt_info)
+ /* skip stmts which do not need to be vectorized. */
+ if (!STMT_VINFO_RELEVANT_P (stmt_info)
&& !STMT_VINFO_LIVE_P (stmt_info))
- {
- if (vect_print_dump_info (REPORT_DETAILS))
- fprintf (vect_dump, "skip.");
- continue;
- }
+ {
+ if (vect_print_dump_info (REPORT_DETAILS))
+ fprintf (vect_dump, "skip.");
+ continue;
+ }
- if (!GIMPLE_STMT_P (stmt)
+ if (!GIMPLE_STMT_P (stmt)
&& VECTOR_MODE_P (TYPE_MODE (TREE_TYPE (stmt))))
- {
- if (vect_print_dump_info (REPORT_UNVECTORIZED_LOOPS))
- {
- fprintf (vect_dump, "not vectorized: vector stmt in loop:");
- print_generic_expr (vect_dump, stmt, TDF_SLIM);
- }
- return false;
- }
+ {
+ if (vect_print_dump_info (REPORT_UNVECTORIZED_LOOPS))
+ {
+ fprintf (vect_dump, "not vectorized: vector stmt in loop:");
+ print_generic_expr (vect_dump, stmt, TDF_SLIM);
+ }
+ return false;
+ }
if (STMT_VINFO_VECTYPE (stmt_info))
{
+ /* The only case when a vectype had been already set is for stmts
+ that contain a dataref, or for "pattern-stmts" (stmts generated
+ by the vectorizer to represent/replace a certain idiom). */
+ gcc_assert (STMT_VINFO_DATA_REF (stmt_info)
+ || is_pattern_stmt_p (stmt_info));
vectype = STMT_VINFO_VECTYPE (stmt_info);
- scalar_type = TREE_TYPE (vectype);
}
else
{
- if (STMT_VINFO_DATA_REF (stmt_info))
- scalar_type =
- TREE_TYPE (DR_REF (STMT_VINFO_DATA_REF (stmt_info)));
- else if (TREE_CODE (stmt) == GIMPLE_MODIFY_STMT)
- scalar_type = TREE_TYPE (GIMPLE_STMT_OPERAND (stmt, 0));
- else
- scalar_type = TREE_TYPE (stmt);
+ gcc_assert (! STMT_VINFO_DATA_REF (stmt_info)
+ && !is_pattern_stmt_p (stmt_info));
+
+ /* We set the vectype according to the type of the result (lhs).
+ For stmts whose result-type is different than the type of the
+ arguments (e.g. demotion, promotion), vectype will be reset
+ appropriately (later). Note that we have to visit the smallest
+ datatype in this function, because that determines the VF.
+ If the samallest datatype in the loop is present only as the
+ rhs of a promotion operation - we'd miss it here.
+ However, in such a case, that a variable of this datatype
+ does not appear in the lhs anywhere in the loop, it shouldn't
+ affect the vectorization factor. */
+ scalar_type = TREE_TYPE (GIMPLE_STMT_OPERAND (stmt, 0));
if (vect_print_dump_info (REPORT_DETAILS))
{
@@ -176,17 +191,17 @@ vect_determine_vectorization_factor (loop_vec_info loop_vinfo)
STMT_VINFO_VECTYPE (stmt_info) = vectype;
}
- if (vect_print_dump_info (REPORT_DETAILS))
- {
- fprintf (vect_dump, "vectype: ");
- print_generic_expr (vect_dump, vectype, TDF_SLIM);
- }
+ if (vect_print_dump_info (REPORT_DETAILS))
+ {
+ fprintf (vect_dump, "vectype: ");
+ print_generic_expr (vect_dump, vectype, TDF_SLIM);
+ }
- nunits = TYPE_VECTOR_SUBPARTS (vectype);
- if (vect_print_dump_info (REPORT_DETAILS))
- fprintf (vect_dump, "nunits = %d", nunits);
+ nunits = TYPE_VECTOR_SUBPARTS (vectype);
+ if (vect_print_dump_info (REPORT_DETAILS))
+ fprintf (vect_dump, "nunits = %d", nunits);
- if (!vectorization_factor
+ if (!vectorization_factor
|| (nunits > vectorization_factor))
vectorization_factor = nunits;
diff --git a/gcc/tree-vect-transform.c b/gcc/tree-vect-transform.c
index 70fa217..846d52b 100644
--- a/gcc/tree-vect-transform.c
+++ b/gcc/tree-vect-transform.c
@@ -665,7 +665,7 @@ vect_get_vec_def_for_operand (tree op, tree stmt, tree *scalar_def)
vector stmt (each computing a vector of 'nunits' results, and together
computing 'VF' results in each iteration). This function is called when
vectorizing such a stmt (e.g. vectorizing S2 in the illustration below, in
- which VF=16 and nuniti=4, so the number of copies required is 4):
+ which VF=16 and nunits=4, so the number of copies required is 4):
scalar stmt: vectorized into: STMT_VINFO_RELATED_STMT
@@ -2171,6 +2171,10 @@ vectorizable_type_demotion (tree stmt, block_stmt_iterator *bsi,
ncopies = LOOP_VINFO_VECT_FACTOR (loop_vinfo) / nunits_out;
gcc_assert (ncopies >= 1);
+
+ if (! INTEGRAL_TYPE_P (scalar_type)
+ || !INTEGRAL_TYPE_P (TREE_TYPE (op0)))
+ return false;
/* Check the operands of the operation. */
if (!vect_is_simple_use (op0, loop_vinfo, &def_stmt, &def, &dt0))
@@ -2377,6 +2381,10 @@ vectorizable_type_promotion (tree stmt, block_stmt_iterator *bsi,
if (nunits_out != nunits_in / 2) /* FORNOW */
return false;
+ if (! INTEGRAL_TYPE_P (TREE_TYPE (scalar_dest))
+ || !INTEGRAL_TYPE_P (TREE_TYPE (op0)))
+ return false;
+
/* Check the operands of the operation. */
if (!vect_is_simple_use (op0, loop_vinfo, &def_stmt, &def, &dt0))
{
@@ -2772,7 +2780,7 @@ vectorizable_store (tree stmt, block_stmt_iterator *bsi, tree *vec_stmt)
S3: &base + 1 = x1
S4: &base + 3 = x3
- We create vectorized storess starting from base address (the access of the
+ We create vectorized stores starting from base address (the access of the
first stmt in the chain (S2 in the above example), when the last store stmt
of the chain (S4) is reached:
@@ -2811,8 +2819,7 @@ vectorizable_store (tree stmt, block_stmt_iterator *bsi, tree *vec_stmt)
as an input to vect_permute_store_chain(), and OPRNDS as an input
to vect_get_vec_def_for_stmt_copy() for the next copy.
If the store is not strided, GROUP_SIZE is 1, and DR_CHAIN and
- OPRNDS are of size 1.
- */
+ OPRNDS are of size 1. */
next_stmt = first_stmt;
for (i = 0; i < group_size; i++)
{
@@ -2820,8 +2827,7 @@ vectorizable_store (tree stmt, block_stmt_iterator *bsi, tree *vec_stmt)
is the exact number of stmts in the chain. Therefore, NEXT_STMT
can't be NULL_TREE. In case that there is no interleaving,
GROUP_SIZE is 1, and only one iteration of the loop will be
- executed.
- */
+ executed. */
gcc_assert (next_stmt);
op = GIMPLE_STMT_OPERAND (next_stmt, 1);
vec_oprnd = vect_get_vec_def_for_operand (op, next_stmt, NULL);
@@ -2841,8 +2847,7 @@ vectorizable_store (tree stmt, block_stmt_iterator *bsi, tree *vec_stmt)
and OPRNDS as an input to vect_get_vec_def_for_stmt_copy() for the
next copy.
If the store is not strided, GROUP_SIZE is 1, and DR_CHAIN and
- OPRNDS are of size 1.
- */
+ OPRNDS are of size 1. */
for (i = 0; i < group_size; i++)
{
vec_oprnd = vect_get_vec_def_for_stmt_copy (dt,
@@ -2907,7 +2912,7 @@ vectorizable_store (tree stmt, block_stmt_iterator *bsi, tree *vec_stmt)
}
prev_stmt_info = vinfo_for_stmt (new_stmt);
- next_stmt = DR_GROUP_NEXT_DR (vinfo_for_stmt (next_stmt));
+ next_stmt = DR_GROUP_NEXT_DR (vinfo_for_stmt (next_stmt));
if (!next_stmt)
break;
/* Bump the vector pointer. */
diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h
index 92b5567..f323403 100644
--- a/gcc/tree-vectorizer.h
+++ b/gcc/tree-vectorizer.h
@@ -300,6 +300,21 @@ vinfo_for_stmt (tree stmt)
return ann ? (stmt_vec_info) ann->common.aux : NULL;
}
+static inline bool
+is_pattern_stmt_p (stmt_vec_info stmt_info)
+{
+ tree related_stmt;
+ stmt_vec_info related_stmt_info;
+
+ related_stmt = STMT_VINFO_RELATED_STMT (stmt_info);
+ if (related_stmt
+ && (related_stmt_info = vinfo_for_stmt (related_stmt))
+ && STMT_VINFO_IN_PATTERN_P (related_stmt_info))
+ return true;
+
+ return false;
+}
+
/*-----------------------------------------------------------------*/
/* Info on data references alignment. */
/*-----------------------------------------------------------------*/