From 1684ca6b9baa0353d246613531f4e3ffccb969c8 Mon Sep 17 00:00:00 2001 From: Ira Rosen Date: Tue, 9 Aug 2011 06:02:00 +0000 Subject: [PATCH] re PR tree-optimization/50014 (Assertion failed in vect_get_vec_def_for_stmt_copy) PR tree-optimization/50014 * tree-vect-loop.c (vectorizable_reduction): Get def type before calling vect_get_vec_def_for_stmt_copy (). From-SVN: r177581 --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/vect/pr50014.c | 16 ++++++++++++++++ gcc/tree-vect-loop.c | 16 +++++++++++----- 4 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/vect/pr50014.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2b9fb29a8a5..d7d2cd7574e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2011-08-09 Ira Rosen + + PR tree-optimization/50014 + * tree-vect-loop.c (vectorizable_reduction): Get def type before + calling vect_get_vec_def_for_stmt_copy (). + 2011-08-08 Vladimir Makarov PR rtl-optimization/49990 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 347975d7091..48836028dd6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-08-09 Ira Rosen + + PR tree-optimization/50014 + * gcc.dg/vect/pr50014.c: New test. + 2011-08-08 Martin Jambor PR middle-end/49923 diff --git a/gcc/testsuite/gcc.dg/vect/pr50014.c b/gcc/testsuite/gcc.dg/vect/pr50014.c new file mode 100644 index 00000000000..c04ffec2135 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr50014.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +int f(unsigned char *s, int n) +{ + int sum = 0; + int i; + + for (i = 0; i < n; i++) + sum += 256 * s[i]; + + return sum; +} + +/* { dg-final { cleanup-tree-dump "vect" } } */ + diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c index afd03f28ff1..539bcaabd97 100644 --- a/gcc/tree-vect-loop.c +++ b/gcc/tree-vect-loop.c @@ -4318,7 +4318,7 @@ vectorizable_reduction (gimple stmt, gimple_stmt_iterator *gsi, VEC (tree, heap) *vec_oprnds0 = NULL, *vec_oprnds1 = NULL, *vect_defs = NULL; VEC (gimple, heap) *phis = NULL; int vec_num; - tree def0, def1, tem; + tree def0, def1, tem, op0, op1 = NULL_TREE; /* In case of reduction chain we switch to the first stmt in the chain, but we don't update STMT_INFO, since only the last stmt is marked as reduction @@ -4775,8 +4775,6 @@ vectorizable_reduction (gimple stmt, gimple_stmt_iterator *gsi, /* Handle uses. */ if (j == 0) { - tree op0, op1 = NULL_TREE; - op0 = ops[!reduc_index]; if (op_type == ternary_op) { @@ -4806,11 +4804,19 @@ vectorizable_reduction (gimple stmt, gimple_stmt_iterator *gsi, { if (!slp_node) { - enum vect_def_type dt = vect_unknown_def_type; /* Dummy */ - loop_vec_def0 = vect_get_vec_def_for_stmt_copy (dt, loop_vec_def0); + enum vect_def_type dt; + gimple dummy_stmt; + tree dummy; + + vect_is_simple_use (ops[!reduc_index], loop_vinfo, NULL, + &dummy_stmt, &dummy, &dt); + loop_vec_def0 = vect_get_vec_def_for_stmt_copy (dt, + loop_vec_def0); VEC_replace (tree, vec_oprnds0, 0, loop_vec_def0); if (op_type == ternary_op) { + vect_is_simple_use (op1, loop_vinfo, NULL, &dummy_stmt, + &dummy, &dt); loop_vec_def1 = vect_get_vec_def_for_stmt_copy (dt, loop_vec_def1); VEC_replace (tree, vec_oprnds1, 0, loop_vec_def1); -- 2.30.2