]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR middle-end/71626 (ICE at -O1 and above on x86_64-linux-gnu (in output...
authorJakub Jelinek <jakub@redhat.com>
Thu, 7 Jul 2016 21:53:12 +0000 (23:53 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 7 Jul 2016 21:53:12 +0000 (23:53 +0200)
Backported from mainline
2016-06-28  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/71626
* config/i386/i386.c (ix86_expand_vector_move): For SUBREG of
a constant, force its SUBREG_REG into memory or register instead
of whole op1.

* gcc.c-torture/execute/pr71626-1.c: New test.
* gcc.c-torture/execute/pr71626-2.c: New test.

From-SVN: r238145

gcc/ChangeLog
gcc/config/i386/i386.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/pr71626-1.c [new file with mode: 0644]
gcc/testsuite/gcc.c-torture/execute/pr71626-2.c [new file with mode: 0644]

index 1fc09f34a5dc4f38849efc8239c8be6b65129d74..ef4bc992e3e24173b641f25723b1c16602ff0712 100644 (file)
@@ -1,6 +1,13 @@
 2016-07-07  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2016-06-28  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/71626
+       * config/i386/i386.c (ix86_expand_vector_move): For SUBREG of
+       a constant, force its SUBREG_REG into memory or register instead
+       of whole op1.
+
        2016-06-21  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/71588
index 733e3bdbdf49a00bbde42e1c1587b5c8649a418e..63af6f301e11a11580440483921ee5598433e7ad 100644 (file)
@@ -16918,12 +16918,29 @@ ix86_expand_vector_move (enum machine_mode mode, rtx operands[])
      of the register, once we have that information we may be able
      to handle some of them more efficiently.  */
   if (can_create_pseudo_p ()
-      && register_operand (op0, mode)
       && (CONSTANT_P (op1)
          || (GET_CODE (op1) == SUBREG
              && CONSTANT_P (SUBREG_REG (op1))))
-      && !standard_sse_constant_p (op1))
-    op1 = validize_mem (force_const_mem (mode, op1));
+      && ((register_operand (op0, mode)
+          && !standard_sse_constant_p (op1))
+         /* ix86_expand_vector_move_misalign() does not like constants.  */
+         || (SSE_REG_MODE_P (mode)
+             && MEM_P (op0)
+             && MEM_ALIGN (op0) < align)))
+    {
+      if (GET_CODE (op1) == SUBREG)
+       {
+         machine_mode imode = GET_MODE (SUBREG_REG (op1));
+         rtx r = force_const_mem (imode, SUBREG_REG (op1));
+         if (r)
+           r = validize_mem (r);
+         else
+           r = force_reg (imode, SUBREG_REG (op1));
+         op1 = simplify_gen_subreg (mode, r, imode, SUBREG_BYTE (op1));
+       }
+      else
+       op1 = validize_mem (force_const_mem (mode, op1));
+    }
 
   /* We need to check memory alignment for SSE mode since attribute
      can make operands unaligned.  */
@@ -16934,13 +16951,8 @@ ix86_expand_vector_move (enum machine_mode mode, rtx operands[])
     {
       rtx tmp[2];
 
-      /* ix86_expand_vector_move_misalign() does not like constants ... */
-      if (CONSTANT_P (op1)
-         || (GET_CODE (op1) == SUBREG
-             && CONSTANT_P (SUBREG_REG (op1))))
-       op1 = validize_mem (force_const_mem (mode, op1));
-
-      /* ... nor both arguments in memory.  */
+      /* ix86_expand_vector_move_misalign() does not like both
+        arguments in memory.  */
       if (!register_operand (op0, mode)
          && !register_operand (op1, mode))
        op1 = force_reg (mode, op1);
index 89aa60849019292aab5607eb8754527ce9e9a5ef..bf4e2596e76e385ef6fbbc38a51b96f9db24bc22 100644 (file)
@@ -1,6 +1,12 @@
 2016-07-07  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2016-06-28  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/71626
+       * gcc.c-torture/execute/pr71626-1.c: New test.
+       * gcc.c-torture/execute/pr71626-2.c: New test.
+
        2016-06-21  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/71588
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr71626-1.c b/gcc/testsuite/gcc.c-torture/execute/pr71626-1.c
new file mode 100644 (file)
index 0000000..26cfa96
--- /dev/null
@@ -0,0 +1,19 @@
+/* PR middle-end/71626 */
+
+typedef __INTPTR_TYPE__ V __attribute__((__vector_size__(sizeof (__INTPTR_TYPE__))));
+
+__attribute__((noinline, noclone)) V
+foo ()
+{
+  V v = { (__INTPTR_TYPE__) foo };
+  return v;
+}
+
+int
+main ()
+{
+  V v = foo ();
+  if (v[0] != (__INTPTR_TYPE__) foo)
+    __builtin_abort ();
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr71626-2.c b/gcc/testsuite/gcc.c-torture/execute/pr71626-2.c
new file mode 100644 (file)
index 0000000..4a27c54
--- /dev/null
@@ -0,0 +1,4 @@
+/* PR middle-end/71626 */
+/* { dg-additional-options "-fpic" { target fpic } } */
+
+#include "pr71626-1.c"