From: Ira Rosen <IRAR@il.ibm.com>
To: Ira Rosen <IRAR@il.ibm.com>
Cc: gcc-patches@gcc.gnu.org,
Richard Guenther <richard.guenther@gmail.com>,
Ryan Mansfield <rmansfield@qnx.com>
Subject: [patch] Fix PR 49087 (was Re: Fix crash in vect_is_slp_reduction)
Date: Sun, 22 May 2011 15:39:00 -0000 [thread overview]
Message-ID: <OFD2D58475.C4B522E0-ONC2257898.002A6B67-C2257898.002CFB7E@il.ibm.com> (raw)
In-Reply-To: <OFA36EAB66.8EDE7242-ONC2257896.00582632-C2257896.00593E57@il.ibm.com>
> >
> > No, we shouldn't arrive with a NULL use_stmt here.
>
> I think a proper fix will be to fail if there are no uses.
> I'll prepare a patch on Sunday.
>
Here is the patch. It bails out if LHS has no uses.
Bootstrapped and tested on powerpc64-suse-linux.
Committed.
Ira
ChangeLog:
PR tree-optimization/49087
* tree-vect-loop.c (vect_is_slp_reduction): Fail if
LHS has no uses.
testsuite/ChangeLog:
PR tree-optimization/49087
* gcc.dg/vect/O3-pr49087.c: New test.
Index: tree-vect-loop.c
===================================================================
--- tree-vect-loop.c (revision 174025)
+++ tree-vect-loop.c (working copy)
@@ -1704,7 +1704,7 @@ vect_is_slp_reduction (loop_vec_info loop_info, gi
tree lhs;
imm_use_iterator imm_iter;
use_operand_p use_p;
- int nloop_uses, size = 0;
+ int nloop_uses, size = 0, nuses;
bool found = false;
if (loop != vect_loop)
@@ -1715,9 +1715,11 @@ vect_is_slp_reduction (loop_vec_info loop_info, gi
while (1)
{
nloop_uses = 0;
+ nuses = 0;
FOR_EACH_IMM_USE_FAST (use_p, imm_iter, lhs)
{
use_stmt = USE_STMT (use_p);
+ nuses++;
if (is_gimple_debug (use_stmt))
continue;
@@ -1739,6 +1741,10 @@ vect_is_slp_reduction (loop_vec_info loop_info, gi
return false;
}
+ /* We reached a statement with no uses. */
+ if (nuses == 0)
+ return false;
+
if (found)
break;
Index: testsuite/gcc.dg/vect/O3-pr49087.c
===================================================================
--- testsuite/gcc.dg/vect/O3-pr49087.c (revision 0)
+++ testsuite/gcc.dg/vect/O3-pr49087.c (revision 0)
@@ -0,0 +1,37 @@
+/* { dg-do compile } */
+
+static char func2() { }
+
+struct S0
+{
+ int t;
+};
+
+int g;
+
+struct S0 s0;
+
+int
+foo (int arg)
+{
+ int *ptr = &g;
+ int i, j;
+ for (i = 0; i < 10; i += 1)
+ {
+ for (j = 0; j < 1; j += 1)
+ {
+ int k;
+ if (arg)
+ {
+ int l;
+ for (k = 1; arg < 10; arg = func2 ())
+ {
+ return l;
+ }
+ }
+ *ptr = func2 () ^ s0.t;
+ }
+ }
+}
+
+/* { dg-final { cleanup-tree-dump "vect" } } */
next prev parent reply other threads:[~2011-05-22 8:11 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-20 14:54 Fix crash in vect_is_slp_reduction Ryan Mansfield
2011-05-20 15:11 ` Richard Guenther
2011-05-20 16:51 ` Ira Rosen
2011-05-22 15:39 ` Ira Rosen [this message]
2011-05-20 19:22 ` Ryan Mansfield
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=OFD2D58475.C4B522E0-ONC2257898.002A6B67-C2257898.002CFB7E@il.ibm.com \
--to=irar@il.ibm.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=richard.guenther@gmail.com \
--cc=rmansfield@qnx.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).