Fix BB store group splitting group size compute
authorRichard Biener <rguenther@suse.de>
Tue, 27 Oct 2020 14:55:01 +0000 (15:55 +0100)
committerRichard Biener <rguenther@suse.de>
Tue, 27 Oct 2020 16:02:47 +0000 (17:02 +0100)
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.

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 [new file with mode: 0644]
gcc/tree-vect-slp.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 (file)
index 0000000..ff959c7
--- /dev/null
@@ -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" } } */
index ba43adb..470b67d 100644 (file)
@@ -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))