The following patch solves https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71374
The patch was successfully bootstrapped and tested on x86-64. Committed as rev. 244991.
Index: ChangeLog =================================================================== --- ChangeLog (revision 244990) +++ ChangeLog (working copy) @@ -1,5 +1,11 @@ 2017-01-27 Vladimir Makarov <vmaka...@redhat.com> + PR tree-optimization/71374 + * lra-constraints.c (check_conflict_input_operands): New. + (match_reload): Use it. + +2017-01-27 Vladimir Makarov <vmaka...@redhat.com> + PR target/79131 * lra-assigns.c (find_hard_regno_for_1): Take endianess for into account to calculate conflict_set. Index: testsuite/ChangeLog =================================================================== --- testsuite/ChangeLog (revision 244990) +++ testsuite/ChangeLog (working copy) @@ -1,3 +1,8 @@ +2017-01-27 Vladimir Makarov <vmaka...@redhat.com> + + PR tree-optimization/71374 + * testsuite/gcc.target/i386/pr71374.c: New. + 2017-01-27 Martin Sebor <mse...@redhat.com> PR c++/71290 Index: lra-constraints.c =================================================================== --- lra-constraints.c (revision 244942) +++ lra-constraints.c (working copy) @@ -878,6 +878,29 @@ regno_val_use_in (unsigned int regno, rt return NULL_RTX; } +/* Return true if all current insn non-output operands except INS (it + has a negaitve end marker) do not use pseudos with the same value + as REGNO. */ +static bool +check_conflict_input_operands (int regno, signed char *ins) +{ + int in; + int n_operands = curr_static_id->n_operands; + + for (int nop = 0; nop < n_operands; nop++) + if (! curr_static_id->operand[nop].is_operator + && curr_static_id->operand[nop].type != OP_OUT) + { + for (int i = 0; (in = ins[i]) >= 0; i++) + if (in == nop) + break; + if (in < 0 + && regno_val_use_in (regno, *curr_id->operand_loc[nop]) != NULL_RTX) + return false; + } + return true; +} + /* Generate reloads for matching OUT and INS (array of input operand numbers with end marker -1) with reg class GOAL_CLASS, considering output operands OUTS (similar array to INS) needing to be in different @@ -917,7 +940,9 @@ match_reload (signed char out, signed ch pseudos as reload pseudos can die although original pseudos still live where reload pseudos dies. */ if (REG_P (in_rtx) && (int) REGNO (in_rtx) < lra_new_regno_start - && find_regno_note (curr_insn, REG_DEAD, REGNO (in_rtx))) + && find_regno_note (curr_insn, REG_DEAD, REGNO (in_rtx)) + && (!early_clobber_p + || check_conflict_input_operands(REGNO (in_rtx), ins))) lra_assign_reg_val (REGNO (in_rtx), REGNO (reg)); } else @@ -947,7 +972,10 @@ match_reload (signed char out, signed ch && (int) REGNO (subreg_reg) < lra_new_regno_start && GET_MODE (subreg_reg) == outmode && SUBREG_BYTE (in_rtx) == SUBREG_BYTE (new_in_reg) - && find_regno_note (curr_insn, REG_DEAD, REGNO (subreg_reg))) + && find_regno_note (curr_insn, REG_DEAD, REGNO (subreg_reg)) + && (! early_clobber_p + || check_conflict_input_operands (REGNO (subreg_reg), + ins))) lra_assign_reg_val (REGNO (subreg_reg), REGNO (reg)); } } @@ -1002,6 +1030,8 @@ match_reload (signed char out, signed ch = (! early_clobber_p && ins[1] < 0 && REG_P (in_rtx) && (int) REGNO (in_rtx) < lra_new_regno_start && find_regno_note (curr_insn, REG_DEAD, REGNO (in_rtx)) + && (! early_clobber_p + || check_conflict_input_operands (REGNO (in_rtx), ins)) && (out < 0 || regno_val_use_in (REGNO (in_rtx), out_rtx) == NULL_RTX) && !out_conflict Index: testsuite/gcc.target/i386/pr71374.c =================================================================== --- testsuite/gcc.target/i386/pr71374.c (revision 0) +++ testsuite/gcc.target/i386/pr71374.c (working copy) @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +int a, b, c; +void +foo (void *x, void *y) +{ + __asm__ ("": "=&c" (a), "=&D" (b), "=&S" (c): "r" (y), "2" (y)); +}