diff mbox

Fix PR tree-optimization/50635

Message ID CAKSNEw6F=zBpBDFBTFVZp6NZ9gUMTG5TvqS+xT9282DU1nPM1w@mail.gmail.com
State New
Headers show

Commit Message

Ira Rosen Oct. 9, 2011, 3:09 p.m. UTC
Hi,

In vectorizer pattern recognition when a pattern def_stmt already
exists, we need to mark it properly for the current pattern.
Another problem is that we don't really have to check that TYPE_OUT is
a vector type. It is set by the pattern detection procedures, and if
the type is invalid we fail later in the operation analysis anyway.

Bootstrapped and tested on powerpc64-suse-linux.
Committed.

Ira

ChangeLog:

        PR tree-optimization/50635
        * tree-vect-patterns.c (vect_handle_widen_mult_by_const): Add
        DEF_STMT to the list of statements to be replaced by the
        pattern statements.
        (vect_handle_widen_mult_by_const): Don't check TYPE_OUT.

testsuite/ChangeLog:

        PR tree-optimization/50635
        * gcc.dg/vect/pr50635.c: New test.
diff mbox

Patch

Index: testsuite/gcc.dg/vect/pr50635.c
===================================================================
--- testsuite/gcc.dg/vect/pr50635.c     (revision 0)
+++ testsuite/gcc.dg/vect/pr50635.c     (revision 0)
@@ -0,0 +1,21 @@ 
+/* { dg-do compile } */
+
+typedef signed long int32_t;
+typedef char int8_t;
+
+void f0a(int32_t * result, int32_t * arg1, int8_t * arg2, int32_t temp_3)
+{
+  int idx;
+  for (idx=0;idx<10;idx += 1)
+    {
+      int32_t temp_4;
+      int32_t temp_12;
+
+      temp_4 = (-2 & arg2[idx]) + temp_3;
+      temp_12 = -2 * arg2[idx] + temp_4;
+      result[idx] = temp_12;
+    }
+}
+
+/* { dg-final { cleanup-tree-dump "vect" } } */
+
Index: tree-vect-patterns.c
===================================================================
--- tree-vect-patterns.c        (revision 179718)
+++ tree-vect-patterns.c        (working copy)
@@ -388,6 +388,7 @@  vect_handle_widen_mult_by_const (gimple stmt, tree
           || TREE_TYPE (gimple_assign_lhs (new_stmt)) != new_type)
         return false;

+      VEC_safe_push (gimple, heap, *stmts, def_stmt);
       *oprnd = gimple_assign_lhs (new_stmt);
     }
   else
@@ -1424,8 +1425,6 @@  vect_pattern_recog_1 (vect_recog_func_ptr vect_rec
     {
       /* No need to check target support (already checked by the pattern
          recognition function).  */
-      if (type_out)
-       gcc_assert (VECTOR_MODE_P (TYPE_MODE (type_out)));
       pattern_vectype = type_out ? type_out : type_in;
     }
   else