tree-optimization/102696 - fix SLP discovery for failed BIT_FIELD_REF

Message ID 30q5r9o7-o58o-5770-p684-n435s134p67@fhfr.qr
State New
Headers show
Series
  • tree-optimization/102696 - fix SLP discovery for failed BIT_FIELD_REF
Related show

Commit Message

Jason Merrill via Gcc-patches Oct. 12, 2021, 11:58 a.m.
This fixes a forgotten adjustment of matches[] when we fail SLP
discovery.

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

2021-10-12  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/102696
	* tree-vect-slp.c (vect_build_slp_tree_2): Properly mark
	the tree fatally failed when we reject a BIT_FIELD_REF.

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

-- 
2.31.1

Patch

diff --git a/gcc/testsuite/g++.dg/vect/pr102696.cc b/gcc/testsuite/g++.dg/vect/pr102696.cc
new file mode 100644
index 00000000000..5560354304a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/vect/pr102696.cc
@@ -0,0 +1,16 @@ 
+// { dg-do compile }
+// { dg-additional-options "-O3" }
+// { dg-additional-options "-march=skylake-avx512" { target x86_64-*-* i?86-*-* } }
+
+int a;
+extern bool b[][14];
+char h;
+void f(short g[][14])
+{
+  for (short d = h; d < 21; d += 1)
+    for (unsigned char e = 0; e < 14; e += 1)
+      {
+	a = 0;
+	b[d][e] = g[d][e];
+      }
+}
diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c
index c70d06e5f20..709bcb63686 100644
--- a/gcc/tree-vect-slp.c
+++ b/gcc/tree-vect-slp.c
@@ -1761,6 +1761,7 @@  vect_build_slp_tree_2 (vec_info *vinfo, slp_tree node,
 				       bit_field_size (bfref), &lane))
 	    {
 	      lperm.release ();
+	      matches[0] = false;
 	      return NULL;
 	    }
 	  lperm.safe_push (std::make_pair (0, (unsigned)lane));