re PR tree-optimization/82473 (ICE in vect_get_vec_def_for_stmt_copy, at tree-vect...
authorRichard Biener <rguenther@suse.de>
Fri, 20 Oct 2017 13:43:47 +0000 (13:43 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 20 Oct 2017 13:43:47 +0000 (13:43 +0000)
2017-10-20  Richard Biener  <rguenther@suse.de>

PR tree-optimization/82473
* tree-vect-loop.c (vectorizable_reduction): Properly get at
the largest input type.

* gcc.dg/torture/pr82473.c: New testcase.

From-SVN: r253937

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr82473.c [new file with mode: 0644]
gcc/tree-vect-loop.c

index 4d2bb892ad7912e7bc792e4a8d26bdf809da906b..054907b3feef36694340d8eaf04db7416310cffd 100644 (file)
@@ -1,3 +1,9 @@
+2017-10-20  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/82473
+       * tree-vect-loop.c (vectorizable_reduction): Properly get at
+       the largest input type.
+
 2017-10-20  Igor Tsimbalist  <igor.v.tsimbalist@intel.com>
 
        * c-attribs.c (handle_nocf_check_attribute): New function.
index 2744146268faa77073d6ff18ef2d9bf6e5bae572..d3d10ddb2bd73a3c8c9d608e1d749ff341ac8356 100644 (file)
@@ -1,3 +1,8 @@
+2017-10-20  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/82473
+       * gcc.dg/torture/pr82473.c: New testcase.
+
 2017-10-20  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/82603
diff --git a/gcc/testsuite/gcc.dg/torture/pr82473.c b/gcc/testsuite/gcc.dg/torture/pr82473.c
new file mode 100644 (file)
index 0000000..b12de21
--- /dev/null
@@ -0,0 +1,22 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-ftree-vectorize" } */
+
+void
+zz (int x9, short int gt)
+{
+  if (0)
+    {
+      while (gt < 1)
+       {
+         int pz;
+
+k6:
+         for (pz = 0; pz < 3; ++pz)
+           x9 += gt;
+         ++gt;
+       }
+    }
+
+  if (x9 != 0)
+    goto k6;
+}
index 7a0f9d5ad07a1968ea1a2af0372e59e6b52a4343..7fb09c466285328407e4ce53b9425db52980022f 100644 (file)
@@ -5836,9 +5836,12 @@ vectorizable_reduction (gimple *stmt, gimple_stmt_iterator *gsi,
          reduc_index = i;
          continue;
        }
-      else
+      else if (tem)
        {
-         if (!vectype_in)
+         /* To properly compute ncopies we are interested in the widest
+            input type in case we're looking at a widening accumulation.  */
+         if (!vectype_in
+             || TYPE_VECTOR_SUBPARTS (vectype_in) > TYPE_VECTOR_SUBPARTS (tem))
            vectype_in = tem;
        }