[PATCH] Fix BB store group splitting group size compute

Richard Biener rguenther@suse.de
Tue Oct 27 15:01:10 GMT 2020


This fixes a mistake in the previous change in this area to what
was desired - figure the largest power-of-two group size fitting
in the matching area.

Bootstrap and regtest running on x86_64-unknown-linux-gnu.

2020-10-27  Richard Biener  <rguenther@suse.de>

	* tree-vect-slp.c (vect_build_slp_instance): Use ceil_log2
	to compute maximum group-size.

	* gcc.dg/vect/bb-slp-67.c: New testcase.
---
 gcc/testsuite/gcc.dg/vect/bb-slp-67.c | 16 ++++++++++++++++
 gcc/tree-vect-slp.c                   |  2 +-
 2 files changed, 17 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.dg/vect/bb-slp-67.c

diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-67.c b/gcc/testsuite/gcc.dg/vect/bb-slp-67.c
new file mode 100644
index 00000000000..ff959c7ac96
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/bb-slp-67.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target vect_float } */
+
+float a[6];
+
+void foo (float x, float y)
+{
+  a[0] = 1.;
+  a[1] = 2.;
+  a[2] = 3.;
+  a[3] = 4.;
+  a[4] = 5.;
+  a[5] = x + y;
+}
+
+/* { dg-final { scan-tree-dump "optimized: basic block" "slp2" } } */
diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c
index ba43adb8a7d..470b67d76b5 100644
--- a/gcc/tree-vect-slp.c
+++ b/gcc/tree-vect-slp.c
@@ -2396,7 +2396,7 @@ vect_build_slp_instance (vec_info *vinfo,
 	  tree scalar_type
 	    = TREE_TYPE (DR_REF (STMT_VINFO_DATA_REF (stmt_info)));
 	  tree vectype = get_vectype_for_scalar_type (vinfo, scalar_type,
-						      least_bit_hwi (i));
+						      1 << floor_log2 (i));
 	  unsigned HOST_WIDE_INT const_nunits;
 	  if (vectype
 	      && TYPE_VECTOR_SUBPARTS (vectype).is_constant (&const_nunits))
-- 
2.26.2


More information about the Gcc-patches mailing list