]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR tree-optimization/91665 (ICE in build_vector_from_val, at tree.c...
authorJakub Jelinek <jakub@redhat.com>
Mon, 21 Oct 2019 11:40:48 +0000 (13:40 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 21 Oct 2019 11:40:48 +0000 (13:40 +0200)
Backported from mainline
2019-09-07  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/91665
* tree-vect-loop.c (vectorizable_reduction): Punt if base has type
incompatible with the type of PHI result.

* gcc.dg/vect/pr91665.c: New test.

From-SVN: r277249

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

index 0f40e8efb6d134cdac8599f42495f950d6c5d137..c98ac09f6fa2f4a77a7bb4d9229c4de270cb5f2f 100644 (file)
@@ -1,6 +1,12 @@
 2019-10-21  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2019-09-07  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/91665
+       * tree-vect-loop.c (vectorizable_reduction): Punt if base has type
+       incompatible with the type of PHI result.
+
        2019-09-06  Jakub Jelinek  <jakub@redhat.com>
 
        * function.c (assign_parm_find_data_types): Use RECORD_OR_UNION_TYPE_P
index 1963746212e1752ad6c65be690720bae42dc5cec..c6a1ad795a18e7baf90680507850da3125b0dd6d 100644 (file)
@@ -1,6 +1,11 @@
 2019-10-21  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2019-09-07  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/91665
+       * gcc.dg/vect/pr91665.c: New test.
+
        2019-09-05  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/91001
diff --git a/gcc/testsuite/gcc.dg/vect/pr91665.c b/gcc/testsuite/gcc.dg/vect/pr91665.c
new file mode 100644 (file)
index 0000000..6b69ea0
--- /dev/null
@@ -0,0 +1,15 @@
+/* PR tree-optimization/91665 */
+/* { dg-do compile } */
+/* { dg-additional-options "-Ofast" } */
+
+short int v;
+
+void
+foo (short int x, short int y)
+{
+  short int *p = &v;
+
+  x = 1;
+  while (x != 0)
+    x += ++y || (*p = x);
+}
index 337e078df002676463d5dea5aab040969680795f..0308b26b808eee18a1d4192326ea9cbce033bcc5 100644 (file)
@@ -6445,10 +6445,13 @@ vectorizable_reduction (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
          gcc_assert (TREE_CODE (base) == INTEGER_CST
                      && TREE_CODE (step) == INTEGER_CST);
          cond_reduc_val = NULL_TREE;
+         tree res = PHI_RESULT (STMT_VINFO_STMT (cond_stmt_vinfo));
+         if (!types_compatible_p (TREE_TYPE (res), TREE_TYPE (base)))
+           ;
          /* Find a suitable value, for MAX_EXPR below base, for MIN_EXPR
             above base; punt if base is the minimum value of the type for
             MAX_EXPR or maximum value of the type for MIN_EXPR for now.  */
-         if (tree_int_cst_sgn (step) == -1)
+         else if (tree_int_cst_sgn (step) == -1)
            {
              cond_reduc_op_code = MIN_EXPR;
              if (tree_int_cst_sgn (base) == -1)