re PR middle-end/82556 (internal compiler error in curr_insn_transform, at lra-constr...
authorVladimir Makarov <vmakarov@redhat.com>
Wed, 18 Oct 2017 16:44:27 +0000 (16:44 +0000)
committerVladimir Makarov <vmakarov@gcc.gnu.org>
Wed, 18 Oct 2017 16:44:27 +0000 (16:44 +0000)
2017-10-18  Vladimir Makarov  <vmakarov@redhat.com>

PR middle-end/82556
* lra-constraints.c (curr_insn_transform): Use non-input operand
instead of output one for matched reload.

2017-10-18  Vladimir Makarov  <vmakarov@redhat.com>

PR middle-end/82556
* gcc.target/i386/pr82556.c: New.

From-SVN: r253862

gcc/ChangeLog
gcc/lra-constraints.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr82556.c [new file with mode: 0644]

index 8e056f249cb8a594e67925d9f744303b0cad96e6..59e0910f8a7dbb390d12d3f9e7a367826ff29225 100644 (file)
@@ -1,3 +1,9 @@
+2017-10-18  Vladimir Makarov  <vmakarov@redhat.com>
+
+       PR middle-end/82556
+       * lra-constraints.c (curr_insn_transform): Use non-input operand
+       instead of output one for matched reload.
+
 2017-10-18  Bin Cheng  <bin.cheng@arm.com>
 
        * tree-loop-distribution.c (INCLUDE_ALGORITHM): New header file.
index 4734c072c96fc1f5dc8cc8f8e7fe4ff2c8b4a7c6..6163d7d5056700c603b5feaa6118bc8eece8d893 100644 (file)
@@ -4271,7 +4271,13 @@ curr_insn_transform (bool check_only_p)
        }
       else if (curr_static_id->operand[i].type == OP_IN
               && (curr_static_id->operand[goal_alt_matched[i][0]].type
-                  == OP_OUT))
+                  == OP_OUT
+                  || (curr_static_id->operand[goal_alt_matched[i][0]].type
+                      == OP_INOUT
+                      && (operands_match_p
+                          (*curr_id->operand_loc[i],
+                           *curr_id->operand_loc[goal_alt_matched[i][0]],
+                           -1)))))
        {
          /* generate reloads for input and matched outputs.  */
          match_inputs[0] = i;
@@ -4282,9 +4288,14 @@ curr_insn_transform (bool check_only_p)
                        [goal_alt_number * n_operands + goal_alt_matched[i][0]]
                        .earlyclobber);
        }
-      else if (curr_static_id->operand[i].type == OP_OUT
+      else if ((curr_static_id->operand[i].type == OP_OUT
+               || (curr_static_id->operand[i].type == OP_INOUT
+                   && (operands_match_p
+                       (*curr_id->operand_loc[i],
+                        *curr_id->operand_loc[goal_alt_matched[i][0]],
+                        -1))))
               && (curr_static_id->operand[goal_alt_matched[i][0]].type
-                  == OP_IN))
+                   == OP_IN))
        /* Generate reloads for output and matched inputs.  */
        match_reload (i, goal_alt_matched[i], outputs, goal_alt[i], &before,
                      &after, curr_static_id->operand_alternative
index ee05077ecf09418605e0b0af46316daaa1b176b9..42cdbd6b61a6653b9e8afd51aa670905a41f4213 100644 (file)
@@ -1,3 +1,8 @@
+2017-10-18  Vladimir Makarov  <vmakarov@redhat.com>
+
+       PR middle-end/82556
+       * gcc.target/i386/pr82556.c: New.
+
 2017-10-18  Bin Cheng  <bin.cheng@arm.com>
 
        * gcc.dg/tree-ssa/ldist-17.c: Adjust test string.
diff --git a/gcc/testsuite/gcc.target/i386/pr82556.c b/gcc/testsuite/gcc.target/i386/pr82556.c
new file mode 100644 (file)
index 0000000..409a301
--- /dev/null
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-strict-aliasing -fwrapv -fexcess-precision=standard" } */
+extern int foo();
+typedef struct {
+  char id;
+  unsigned char fork_flags;
+  short data_length;
+} Header;
+int a;
+void X() {
+  do {
+    char* b;
+    Header c;
+    if (a)
+      c.fork_flags |= 1;
+    __builtin_memcpy(b, &c, __builtin_offsetof(Header, data_length));
+    b += foo();
+  } while (1);
+}