aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2020-09-21 16:51:33 +0200
committerRichard Biener <rguenther@suse.de>2020-09-21 16:54:04 +0200
commite6f58fb6196ba16ce070e3722451f040a13f963b (patch)
tree5002dfc3bf0db9e8c32733172c4646345fba7eb7
parentb6ff694e592669e7865d39a884100dd677e7ceec (diff)
downloadgcc-e6f58fb6196ba16ce070e3722451f040a13f963b.zip
gcc-e6f58fb6196ba16ce070e3722451f040a13f963b.tar.gz
gcc-e6f58fb6196ba16ce070e3722451f040a13f963b.tar.bz2
tree-optimization/97139 - fix BB SLP live lane extraction
This fixes SLP live lane extraction with pattern stmts. 2020-09-21 Richard Biener <rguenther@suse.de> PR tree-optimization/97139 * tree-vect-slp.c (vect_bb_slp_mark_live_stmts): Only mark the pattern root, track visited vectorized stmts. * gcc.dg/vect/pr97139.c: New testcase.
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr97139.c27
-rw-r--r--gcc/tree-vect-slp.c10
2 files changed, 34 insertions, 3 deletions
diff --git a/gcc/testsuite/gcc.dg/vect/pr97139.c b/gcc/testsuite/gcc.dg/vect/pr97139.c
new file mode 100644
index 0000000..1b9f31c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr97139.c
@@ -0,0 +1,27 @@
+/* { dg-require-effective-target vect_int } */
+
+#include "tree-vect.h"
+
+int pix[4];
+
+int __attribute__((noipa)) foo (void)
+{
+ pix[0] = pix[0] / 4;
+ pix[1] = pix[1] / 4;
+ pix[2] = pix[2] / 4;
+ pix[3] = pix[3] / 4;
+ return pix[0] + pix[1] + pix[2] + pix[3];
+}
+
+int main ()
+{
+ check_vect ();
+
+ pix[0] = 8;
+ pix[1] = 16;
+ pix[2] = 32;
+ pix[3] = 64;
+ if (foo () != 30)
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c
index ef62c2d..c44fd39 100644
--- a/gcc/tree-vect-slp.c
+++ b/gcc/tree-vect-slp.c
@@ -3021,10 +3021,14 @@ vect_bb_slp_mark_live_stmts (bb_vec_info bb_vinfo, slp_tree node,
bool all_visited = true;
FOR_EACH_VEC_ELT (SLP_TREE_SCALAR_STMTS (node), i, stmt_info)
{
- stmt_vec_info orig_stmt_info = vect_orig_stmt (stmt_info);
- if (svisited.contains (orig_stmt_info))
+ if (svisited.contains (stmt_info))
continue;
all_visited = false;
+ stmt_vec_info orig_stmt_info = vect_orig_stmt (stmt_info);
+ if (STMT_VINFO_IN_PATTERN_P (orig_stmt_info)
+ && STMT_VINFO_RELATED_STMT (orig_stmt_info) != stmt_info)
+ /* Only the pattern root stmt computes the original scalar value. */
+ continue;
bool mark_visited = true;
gimple *orig_stmt = orig_stmt_info->stmt;
ssa_op_iter op_iter;
@@ -3091,7 +3095,7 @@ vect_bb_slp_mark_live_stmts (bb_vec_info bb_vinfo, slp_tree node,
}
}
if (mark_visited)
- svisited.add (orig_stmt_info);
+ svisited.add (stmt_info);
}
if (all_visited)
return;