aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2020-06-22 12:14:54 +0200
committerRichard Biener <rguenther@suse.de>2020-06-22 12:17:41 +0200
commitcf07eea8429c923b7eb884ffc1b267c80a0a839c (patch)
tree5c9e8711ab9a57ba8fdb02c6549202d2fbb96568 /gcc
parentd32495261a8a9d35379180d8ad0bca693f06b104 (diff)
downloadgcc-cf07eea8429c923b7eb884ffc1b267c80a0a839c.zip
gcc-cf07eea8429c923b7eb884ffc1b267c80a0a839c.tar.gz
gcc-cf07eea8429c923b7eb884ffc1b267c80a0a839c.tar.bz2
tree-optimization/95770 - fix SLP vectorized stmt placement compute
This fixes the vectorized stmt placement compute for the case of external defs. 2020-06-22 Richard Biener <rguenther@suse.de> PR tree-optimization/95770 * tree-vect-slp.c (vect_schedule_slp_instance): Also consider external defs. * gcc.dg/pr95770.c: New testcase.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/gcc.dg/pr95770.c9
-rw-r--r--gcc/tree-vect-slp.c18
2 files changed, 24 insertions, 3 deletions
diff --git a/gcc/testsuite/gcc.dg/pr95770.c b/gcc/testsuite/gcc.dg/pr95770.c
new file mode 100644
index 0000000..06714ea
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr95770.c
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options "-O3" } */
+
+float *a;
+void b(float c, float d)
+{
+ a[0] = a[1] = 0.5f * (c - 2 + d);
+ a[2] = a[3] = 0.5f * (c + 2 + d);
+}
diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c
index 5c169f3..4031db4 100644
--- a/gcc/tree-vect-slp.c
+++ b/gcc/tree-vect-slp.c
@@ -4216,9 +4216,6 @@ vect_schedule_slp_instance (vec_info *vinfo,
children vectorized defs. */
gimple *last_stmt = NULL;
FOR_EACH_VEC_ELT (SLP_TREE_CHILDREN (node), i, child)
- /* ??? With only external defs the following breaks. Note
- external defs do not get all vector init stmts generated
- at the same place. */
if (SLP_TREE_DEF_TYPE (child) == vect_internal_def)
{
/* We are emitting all vectorized stmts in the same place and
@@ -4232,6 +4229,21 @@ vect_schedule_slp_instance (vec_info *vinfo,
|| vect_stmt_dominates_stmt_p (last_stmt, vstmt))
last_stmt = vstmt;
}
+ else
+ {
+ /* For externals we have to look at all defs since their
+ insertion place is decided per vector. */
+ unsigned j;
+ tree vdef;
+ FOR_EACH_VEC_ELT (SLP_TREE_VEC_DEFS (child), j, vdef)
+ if (TREE_CODE (vdef) == SSA_NAME)
+ {
+ gimple *vstmt = SSA_NAME_DEF_STMT (vdef);
+ if (!last_stmt
+ || vect_stmt_dominates_stmt_p (last_stmt, vstmt))
+ last_stmt = vstmt;
+ }
+ }
if (is_a <gphi *> (last_stmt))
si = gsi_after_labels (gimple_bb (last_stmt));
else