This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
patch to fix PR82556
- From: Vladimir Makarov <vmakarov at redhat dot com>
- To: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 18 Oct 2017 12:52:44 -0400
- Subject: patch to fix PR82556
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=vmakarov at redhat dot com
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4AED81E328
The following patch fixes
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82556
The patch was bootstrapped and tested on x86-64.
Committed to trunk as rev. 253862.
Committed to gcc-7-branch as rev. 253863.
Index: ChangeLog
===================================================================
--- ChangeLog (revision 253862)
+++ ChangeLog (working copy)
@@ -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-17 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/82549
Index: testsuite/ChangeLog
===================================================================
--- testsuite/ChangeLog (revision 253862)
+++ testsuite/ChangeLog (working copy)
@@ -1,3 +1,8 @@
+2017-10-18 Vladimir Makarov <vmakarov@redhat.com>
+
+ PR middle-end/82556
+ * gcc.target/i386/pr82556.c: New.
+
2017-10-17 Eric Botcazou <ebotcazou@adacore.com>
* gcc.dg/attr-alloc_size-11.c: UnXFAIL for visium-*-*.
Index: lra-constraints.c
===================================================================
--- lra-constraints.c (revision 253815)
+++ lra-constraints.c (working copy)
@@ -4284,7 +4284,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;
@@ -4295,9 +4301,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: testsuite/gcc.target/i386/pr82556.c
===================================================================
--- testsuite/gcc.target/i386/pr82556.c (nonexistent)
+++ testsuite/gcc.target/i386/pr82556.c (working copy)
@@ -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);
+}