Hello,

one of Ira's vectorizer patches I recently committed seems to have exposed
a pre-existing bug in handling WIDEN_LSHIFT_EXPR, which now causes ICEs
in SLP due to out-of-bounds memory accesses.

The underlying cause is that vect_get_smallest_scalar_type does not handle
WIDEN_LSHIFT_EXPR as it does the other widening operations.  This causes
the SLP pass to operate on the wrong type and thus get confused about the
number of vector instructions it need to allocate space for.

The following patch fixes all those ICEs for me.  Manual checking shows
that widening shifts are now recognized correctly by SLP.

Tested with no regression on armv7l-linux-gnueabi and i686-linux-gnu.

OK for mainline?

Bye,
Ulrich


ChangeLog:

        gcc/
        PR tree-optimization/52686
        * tree-vect-data-refs.c (vect_get_smallest_scalar_type): Handle
        WIDEN_LSHIFT_EXPR.

        gcc/testsuite/
        PR tree-optimization/52686
        * gcc.target/arm/pr52686.c: New test.


Index: gcc/testsuite/gcc.target/arm/pr52686.c
===================================================================
--- gcc/testsuite/gcc.target/arm/pr52686.c      (revision 0)
+++ gcc/testsuite/gcc.target/arm/pr52686.c      (revision 0)
@@ -0,0 +1,19 @@
+/* PR target/52375 */
+/* { dg-do compile } */
+/* { dg-require-effective-target arm_neon_ok } */
+/* { dg-options "-march=armv7-a -mfloat-abi=softfp -mfpu=neon -O 
-ftree-vectorize" } */
+
+unsigned int output[4];
+
+void test (unsigned short *p)
+{
+  unsigned int x = *p;
+  if (x)
+    {
+      output[0] = x << 1;
+      output[1] = x << 1;
+      output[2] = x << 1;
+      output[3] = x << 1;
+    }
+}
+
Index: gcc/tree-vect-data-refs.c
===================================================================
--- gcc/tree-vect-data-refs.c   (revision 185467)
+++ gcc/tree-vect-data-refs.c   (working copy)
@@ -111,6 +111,7 @@
   if (is_gimple_assign (stmt)
       && (gimple_assign_cast_p (stmt)
           || gimple_assign_rhs_code (stmt) == WIDEN_MULT_EXPR
+          || gimple_assign_rhs_code (stmt) == WIDEN_LSHIFT_EXPR
           || gimple_assign_rhs_code (stmt) == FLOAT_EXPR))
     {
       tree rhs_type = TREE_TYPE (gimple_assign_rhs1 (stmt));
-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  ulrich.weig...@de.ibm.com

Reply via email to