This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix a couple of tree-vect-loop.c issues
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Richard Biener <rguenther at suse dot de>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Thu, 13 Feb 2014 23:46:38 +0100
- Subject: [PATCH] Fix a couple of tree-vect-loop.c issues
- Authentication-results: sourceware.org; auth=none
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
While fixing a -O3 -g vectorizer ICE that only reproduced on GCC-4.4-RH
branch, I've noticed couple of similar issues on the trunk.
The first hunk is just a cleanup, there is no point to set use_stmt again to
the same thing as it has been set before.
The second and third hunks are to ignore debug stmts, other places in
tree-vect-loop.c that similarly look for the exit phi look similarly.
The last hunk fixes GOMP_SIMD_LANE handling, and the testcase is
from the FAIL in redhat/gcc-4_4-branch.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
2014-02-13 Jakub Jelinek <jakub@redhat.com>
* tree-vect-loop.c (vect_is_slp_reduction): Don't set
use_stmt twice.
(get_initial_def_for_induction, vectorizable_induction): Ignore
debug stmts when looking for exit_phi.
(vectorizable_live_operation): Fix up condition.
* gcc.c-torture/compile/20140213.c: New test.
--- gcc/tree-vect-loop.c.jj 2014-02-05 15:28:10.000000000 +0100
+++ gcc/tree-vect-loop.c 2014-02-13 15:36:38.117741038 +0100
@@ -1968,10 +1968,8 @@ vect_is_slp_reduction (loop_vec_info loo
FOR_EACH_IMM_USE_FAST (use_p, imm_iter, lhs)
{
gimple use_stmt = USE_STMT (use_p);
- if (is_gimple_debug (use_stmt))
- continue;
-
- use_stmt = USE_STMT (use_p);
+ if (is_gimple_debug (use_stmt))
+ continue;
/* Check if we got back to the reduction phi. */
if (use_stmt == phi)
@@ -3507,9 +3505,13 @@ get_initial_def_for_induction (gimple iv
exit_phi = NULL;
FOR_EACH_IMM_USE_FAST (use_p, imm_iter, loop_arg)
{
- if (!flow_bb_inside_loop_p (iv_loop, gimple_bb (USE_STMT (use_p))))
+ gimple use_stmt = USE_STMT (use_p);
+ if (is_gimple_debug (use_stmt))
+ continue;
+
+ if (!flow_bb_inside_loop_p (iv_loop, gimple_bb (use_stmt)))
{
- exit_phi = USE_STMT (use_p);
+ exit_phi = use_stmt;
break;
}
}
@@ -5413,10 +5415,13 @@ vectorizable_induction (gimple phi, gimp
loop_arg = PHI_ARG_DEF_FROM_EDGE (phi, latch_e);
FOR_EACH_IMM_USE_FAST (use_p, imm_iter, loop_arg)
{
- if (!flow_bb_inside_loop_p (loop->inner,
- gimple_bb (USE_STMT (use_p))))
+ gimple use_stmt = USE_STMT (use_p);
+ if (is_gimple_debug (use_stmt))
+ continue;
+
+ if (!flow_bb_inside_loop_p (loop->inner, gimple_bb (use_stmt)))
{
- exit_phi = USE_STMT (use_p);
+ exit_phi = use_stmt;
break;
}
}
@@ -5514,7 +5519,7 @@ vectorizable_live_operation (gimple stmt
{
gimple use_stmt = USE_STMT (use_p);
if (gimple_code (use_stmt) == GIMPLE_PHI
- || gimple_bb (use_stmt) == merge_bb)
+ && gimple_bb (use_stmt) == merge_bb)
{
if (vec_stmt)
{
--- gcc/testsuite/gcc.c-torture/compile/20140213.c.jj 2013-08-25 18:20:55.717911035 +0200
+++ gcc/testsuite/gcc.c-torture/compile/20140213.c 2014-02-13 16:23:45.631401820 +0100
@@ -0,0 +1,21 @@
+static unsigned short
+foo (unsigned char *x, int y)
+{
+ unsigned short r = 0;
+ int i;
+ for (i = 0; i < y; i++)
+ r += x[i];
+ return r;
+}
+
+int baz (int, unsigned short);
+
+void
+bar (unsigned char *x, unsigned char *y)
+{
+ int i;
+ unsigned short key = foo (x, 0x10000);
+ baz (0, 0);
+ for (i = 0; i < 0x80000; i++)
+ y[i] = x[baz (i, key)];
+}
Jakub