* [patch] Fix PR tree-optimization/50014
@ 2011-08-09 8:14 Ira Rosen
0 siblings, 0 replies; only message in thread
From: Ira Rosen @ 2011-08-09 8:14 UTC (permalink / raw)
To: gcc-patches; +Cc: Patch Tracking
Hi,
In vectorization of reduction we use a dummy def_type when getting a
copy of a vector operand. Therefore, instead of just using a constant
operand from a previous copy, we try to create a copy of it, causing
the failure. This patch adds a call to vect_is_simple_use () to get a
correct def_type.
Bootstrapped and tested on powerpc64-suse-linux.
Committed.
Ira
ChangeLog:
PR tree-optimization/50014
* tree-vect-loop.c (vectorizable_reduction): Get def type before
calling vect_get_vec_def_for_stmt_copy ().
testsuite/ChangeLog:
PR tree-optimization/50014
* gcc.dg/vect/pr50014.c: New test.
Index: tree-vect-loop.c
===================================================================
--- tree-vect-loop.c (revision 177580)
+++ tree-vect-loop.c (working copy)
@@ -4318,7 +4318,7 @@ vectorizable_reduction (gimple stmt, gimple_stmt_i
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_i
/* 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_i
{
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);
Index: testsuite/gcc.dg/vect/pr50014.c
===================================================================
--- testsuite/gcc.dg/vect/pr50014.c (revision 0)
+++ testsuite/gcc.dg/vect/pr50014.c (revision 0)
@@ -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" } } */
+
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2011-08-09 6:03 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-09 8:14 [patch] Fix PR tree-optimization/50014 Ira Rosen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).