This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/39698] wrong types for vectorized reduction
- From: "irar at il dot ibm dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 16 Apr 2009 10:26:33 -0000
- Subject: [Bug tree-optimization/39698] wrong types for vectorized reduction
- References: <bug-39698-10053@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #2 from irar at il dot ibm dot com 2009-04-16 10:26 -------
This patch fixes the type in pr34591.c (the vector type should be the type of
the reduction variable because we are looking for its initial value, and not
the type of the reduction statement, i.e., its RHS type):
Index: tree-vect-loop.c
===================================================================
--- tree-vect-loop.c (revision 145457)
+++ tree-vect-loop.c (working copy)
@@ -2267,33 +2267,33 @@ get_initial_def_for_reduction (gimple st
stmt_vec_info stmt_vinfo = vinfo_for_stmt (stmt);
loop_vec_info loop_vinfo = STMT_VINFO_LOOP_VINFO (stmt_vinfo);
struct loop *loop = LOOP_VINFO_LOOP (loop_vinfo);
- tree vectype = STMT_VINFO_VECTYPE (stmt_vinfo);
- int nunits = TYPE_VECTOR_SUBPARTS (vectype);
- tree scalar_type = TREE_TYPE (vectype);
+ tree scalar_type = TREE_TYPE (init_val);
+ tree vectype = get_vectype_for_scalar_type (scalar_type);
+ int nunits;
enum tree_code code = gimple_assign_rhs_code (stmt);
- tree type = TREE_TYPE (init_val);
- tree vecdef;
tree def_for_init;
tree init_def;
tree t = NULL_TREE;
int i;
bool nested_in_vect_loop = false;
- gcc_assert (POINTER_TYPE_P (type) || INTEGRAL_TYPE_P (type) ||
SCALAR_FLOAT_TYPE_P (type));
+ gcc_assert (vectype);
+ nunits = TYPE_VECTOR_SUBPARTS (vectype);
+
+ gcc_assert (POINTER_TYPE_P (scalar_type) || INTEGRAL_TYPE_P (scalar_type)
+ || SCALAR_FLOAT_TYPE_P (scalar_type));
if (nested_in_vect_loop_p (loop, stmt))
nested_in_vect_loop = true;
else
gcc_assert (loop == (gimple_bb (stmt))->loop_father);
- vecdef = vect_get_vec_def_for_operand (init_val, stmt, NULL);
-
switch (code)
case WIDEN_SUM_EXPR:
case DOT_PROD_EXPR:
case PLUS_EXPR:
if (nested_in_vect_loop)
- *adjustment_def = vecdef;
+ *adjustment_def = vect_get_vec_def_for_operand (init_val, stmt, NULL);
else
*adjustment_def = init_val;
/* Create a vector of zeros for init_def. */
@@ -2310,7 +2310,7 @@ get_initial_def_for_reduction (gimple st
case MIN_EXPR:
case MAX_EXPR:
*adjustment_def = NULL_TREE;
- init_def = vecdef;
+ init_def = vect_get_vec_def_for_operand (init_val, stmt, NULL);
break;
default:
(I also removed the creation of definition for the cases where it is not used).
Tested on vectorizer testsuite.
Ira
--
irar at il dot ibm dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2009-04-16 10:26:32
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39698