re PR tree-optimization/65930 (Reduction with sign-change not handled)
authorRichard Biener <rguenther@suse.de>
Wed, 23 Oct 2019 12:41:49 +0000 (12:41 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 23 Oct 2019 12:41:49 +0000 (12:41 +0000)
2019-10-23  Richard Biener  <rguenther@suse.de>

PR tree-optimization/65930
* tree-vect-loop.c (check_reduction_path): Allow conversions
that only change the sign.
(vectorizable_reduction): Relax latch def stmts we handle further.

* gcc.dg/vect/vect-reduc-2char-big-array.c: Adjust.
* gcc.dg/vect/vect-reduc-2char.c: Likewise.
* gcc.dg/vect/vect-reduc-2short.c: Likewise.
* gcc.dg/vect/vect-reduc-dot-s8b.c: Likewise.
* gcc.dg/vect/vect-reduc-pattern-2c.c: Likewise.

From-SVN: r277322

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/vect/vect-reduc-2char-big-array.c
gcc/testsuite/gcc.dg/vect/vect-reduc-2char.c
gcc/testsuite/gcc.dg/vect/vect-reduc-2short.c
gcc/testsuite/gcc.dg/vect/vect-reduc-dot-s8b.c
gcc/testsuite/gcc.dg/vect/vect-reduc-pattern-2c.c
gcc/tree-vect-loop.c

index 23a7d18b3cd03c0c541e6ecaa3800977c6495239..508207dfc51a35b0e9645ee2957839e76421207e 100644 (file)
@@ -1,3 +1,10 @@
+2019-10-23  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/65930
+       * tree-vect-loop.c (check_reduction_path): Allow conversions
+       that only change the sign.
+       (vectorizable_reduction): Relax latch def stmts we handle further.
+
 2019-10-23  Jakub Jelinek  <jakub@redhat.com>
 
        PR debug/90231
index 790ffe4bf6d10f8bc86e6d4114d459a72d9f751d..a9c44136a2c75efc42818dc01d13b1d3728ba815 100644 (file)
@@ -1,3 +1,12 @@
+2019-10-23  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/65930
+       * gcc.dg/vect/vect-reduc-2char-big-array.c: Adjust.
+       * gcc.dg/vect/vect-reduc-2char.c: Likewise.
+       * gcc.dg/vect/vect-reduc-2short.c: Likewise.
+       * gcc.dg/vect/vect-reduc-dot-s8b.c: Likewise.
+       * gcc.dg/vect/vect-reduc-pattern-2c.c: Likewise.
+
 2019-10-23  Jakub Jelinek  <jakub@redhat.com>
 
        * g++.dg/cpp2a/constexpr-dtor3.C: Expect in 'constexpr' expansion of
index e246ae7f3c6c8a64fdc682a224d924f387840b0c..c40f8625b8485129439a08b3842fd2254cdc5990 100644 (file)
@@ -62,4 +62,4 @@ int main (void)
   return 0;
 }
 
-/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" { xfail *-*-* } } } */
+/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" } } */
index 5f0551ee372ab2823c3c71a300dde2c8ac639aa6..dd3045502f1831a7775cc655934e98f4a048ea0e 100644 (file)
@@ -46,4 +46,4 @@ int main (void)
   return 0;
 }
 
-/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" { xfail *-*-* } } } */
+/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" } } */
index 02c2bee86124604451077fba87b7ca9848182438..1a2d8d04f4e8618be153ef5aa2a6605d2217bbaf 100644 (file)
@@ -45,4 +45,4 @@ int main (void)
   return 0;
 }
 
-/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" { xfail *-*-* } } } */
+/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" } } */
index b036ad5b0b4e8519c4fd1df9deb96e9281d62f2a..c0ee5dc01c576065d1b2d06978444b7b39808fbd 100644 (file)
@@ -12,12 +12,6 @@ signed char Y[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
 
 /* char->short->short dot product.
    The dot-product pattern should be detected.
-   The reduction is currently not vectorized becaus of the signed->unsigned->signed
-   casts, since this patch:
-
-     2005-12-26  Kazu Hirata  <kazu@codesourcery.com>
-                                                                                                
-        PR tree-optimization/25125
 
    When the dot-product is detected, the loop should be vectorized on vect_sdot_qi 
    targets (targets that support dot-product of signed char).  
@@ -60,5 +54,5 @@ int main (void)
 /* { dg-final { scan-tree-dump-times "vect_recog_dot_prod_pattern: detected" 1 "vect" { xfail *-*-* } } } */
 /* { dg-final { scan-tree-dump-times "vect_recog_widen_mult_pattern: detected" 1 "vect" } } */
 
-/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
 
index 8190622d5d7472aa8b4e350e120415cb69d468b7..71df5741e16b44fe7e136cfd465a793c7dad0c20 100644 (file)
@@ -21,6 +21,8 @@ foo ()
      2005-12-26  Kazu Hirata  <kazu@codesourcery.com>
                                                                                 
         PR tree-optimization/25125
+
+     but we still handle the reduction.
    */
 
   for (i = 0; i < N; i++)
@@ -43,5 +45,4 @@ main (void)
 }
 
 /* { dg-final { scan-tree-dump-times "vect_recog_widen_sum_pattern: detected" 1 "vect" { xfail *-*-* } } } */
-/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */
-/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" { target { ! vect_widen_sum_qi_to_hi } } } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
index e22d2dd7abbf43aa0c8707b9422b90612188ad2a..b66f211c350dee8153c0e29044baef8b35aac2b6 100644 (file)
@@ -2695,7 +2695,11 @@ pop:
          if (gimple_assign_rhs2 (use_stmt) == op)
            neg = ! neg;
        }
-      if (*code == ERROR_MARK)
+      if (CONVERT_EXPR_CODE_P (use_code)
+         && tree_nop_conversion_p (TREE_TYPE (gimple_assign_lhs (use_stmt)),
+                                   TREE_TYPE (gimple_assign_rhs1 (use_stmt))))
+       ;
+      else if (*code == ERROR_MARK)
        *code = use_code;
       else if (use_code != *code)
        {
@@ -5692,19 +5696,6 @@ vectorizable_reduction (stmt_vec_info stmt_info, slp_tree slp_node,
         which is defined by the loop-header-phi.  */
 
   gassign *stmt = as_a <gassign *> (stmt_info->stmt);
-  switch (get_gimple_rhs_class (gimple_assign_rhs_code (stmt)))
-    {
-    case GIMPLE_BINARY_RHS:
-    case GIMPLE_TERNARY_RHS:
-      break;
-
-    case GIMPLE_UNARY_RHS:
-    case GIMPLE_SINGLE_RHS:
-      return false;
-
-    default:
-      gcc_unreachable ();
-    }
   enum tree_code code = gimple_assign_rhs_code (stmt);
   int op_type = TREE_CODE_LENGTH (code);