]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR rtl-optimization/87065 (combine causes ICE in trunc_int_for_mode)
authorJakub Jelinek <jakub@redhat.com>
Fri, 12 Oct 2018 17:32:38 +0000 (19:32 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 12 Oct 2018 17:32:38 +0000 (19:32 +0200)
Backported from mainline
2018-08-27  Jakub Jelinek  <jakub@redhat.com>

PR rtl-optimization/87065
* combine.c (simplify_if_then_else): Formatting fix.
(if_then_else_cond): Guard MULT optimization with SCALAR_INT_MODE_P
check.
(known_cond): Don't return const_true_rtx for vector modes.  Use
CONST0_RTX instead of const0_rtx.  Formatting fixes.

* gcc.target/i386/pr87065.c: New test.

From-SVN: r265120

gcc/ChangeLog
gcc/combine.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr87065.c [new file with mode: 0644]

index c09e3c77a846a9544a913d48d12f16c47325d4e1..8a5d1f3ae938268a96074ee468fa1ca04038bbd4 100644 (file)
@@ -1,6 +1,15 @@
 2018-10-12  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2018-08-27  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/87065
+       * combine.c (simplify_if_then_else): Formatting fix.
+       (if_then_else_cond): Guard MULT optimization with SCALAR_INT_MODE_P
+       check.
+       (known_cond): Don't return const_true_rtx for vector modes.  Use
+       CONST0_RTX instead of const0_rtx.  Formatting fixes.
+
        2018-07-24  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/86627
index b6024bf075d8e241b9905348e8afc544b47d5d94..ed07cb690783684089df3e7063e6f27c78f00eb9 100644 (file)
@@ -6277,7 +6277,7 @@ simplify_if_then_else (rtx x)
                          pc_rtx, pc_rtx, 0, 0, 0);
       if (reg_mentioned_p (from, false_rtx))
        false_rtx = subst (known_cond (copy_rtx (false_rtx), false_code,
-                                  from, false_val),
+                                      from, false_val),
                           pc_rtx, pc_rtx, 0, 0, 0);
 
       SUBST (XEXP (x, 1), swapped ? false_rtx : true_rtx);
@@ -9035,6 +9035,7 @@ if_then_else_cond (rtx x, rtx *ptrue, rtx *pfalse)
 
          if (COMPARISON_P (cond0)
              && COMPARISON_P (cond1)
+             && SCALAR_INT_MODE_P (mode)
              && ((GET_CODE (cond0) == reversed_comparison_code (cond1, NULL)
                   && rtx_equal_p (XEXP (cond0, 0), XEXP (cond1, 0))
                   && rtx_equal_p (XEXP (cond0, 1), XEXP (cond1, 1)))
@@ -9183,12 +9184,12 @@ known_cond (rtx x, enum rtx_code cond, rtx reg, rtx val)
          if (COMPARISON_P (x))
            {
              if (comparison_dominates_p (cond, code))
-               return const_true_rtx;
+               return VECTOR_MODE_P (GET_MODE (x)) ? x : const_true_rtx;
 
              code = reversed_comparison_code (x, NULL);
              if (code != UNKNOWN
                  && comparison_dominates_p (cond, code))
-               return const0_rtx;
+               return CONST0_RTX (GET_MODE (x));
              else
                return x;
            }
@@ -9231,7 +9232,7 @@ known_cond (rtx x, enum rtx_code cond, rtx reg, rtx val)
          /* We must simplify subreg here, before we lose track of the
             original inner_mode.  */
          new_rtx = simplify_subreg (GET_MODE (x), r,
-                                inner_mode, SUBREG_BYTE (x));
+                                    inner_mode, SUBREG_BYTE (x));
          if (new_rtx)
            return new_rtx;
          else
@@ -9256,7 +9257,7 @@ known_cond (rtx x, enum rtx_code cond, rtx reg, rtx val)
          /* We must simplify the zero_extend here, before we lose
             track of the original inner_mode.  */
          new_rtx = simplify_unary_operation (ZERO_EXTEND, GET_MODE (x),
-                                         r, inner_mode);
+                                             r, inner_mode);
          if (new_rtx)
            return new_rtx;
          else
index 986f6b6fdd5f0a67ea9c31e2b42ffb1ca9a47a59..41f3b0b879158a47fb3f12a4855980526f30f2b5 100644 (file)
@@ -1,6 +1,11 @@
 2018-10-12  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2018-08-27  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/87065
+       * gcc.target/i386/pr87065.c: New test.
+
        2018-07-24  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/86627
diff --git a/gcc/testsuite/gcc.target/i386/pr87065.c b/gcc/testsuite/gcc.target/i386/pr87065.c
new file mode 100644 (file)
index 0000000..f1cc6f9
--- /dev/null
@@ -0,0 +1,22 @@
+/* PR rtl-optimization/87065 */
+/* { dg-do compile } */
+/* { dg-options "-O3 -mxop -mprefer-avx128" } */
+
+int a, c, d, e;
+short *b;
+
+void
+foo (void)
+{
+  short *g = b;
+  int h = 1;
+  unsigned i;
+  for (; h <= 1; h++)
+    g = (short *) &c;
+  for (; c; c++)
+    {
+      for (; i <= 1; i++)
+       ;
+      a ^= (a > 0 <= i) + ((e += d) == 0 ?: (*g = 8));
+    }
+}