The following patch fixes https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84985
The patch was successfully bootstrapped and tested on x86-64. Committed as rev. 258961.
Index: ChangeLog =================================================================== --- ChangeLog (revision 258960) +++ ChangeLog (working copy) @@ -1,3 +1,9 @@ +2018-03-29 Vladimir Makarov <vmaka...@redhat.com> + + PR inline-asm/84985 + * lra-constraints.c (process_alt_operands): Move setting + this_alternative_matches below. + 2018-03-29 Martin Liska <mli...@suse.cz> PR lto/84995. Index: testsuite/ChangeLog =================================================================== --- testsuite/ChangeLog (revision 258960) +++ testsuite/ChangeLog (working copy) @@ -1,3 +1,8 @@ +2018-03-29 Vladimir Makarov <vmaka...@redhat.com> + + PR inline-asm/84985 + * gcc.target/i386/pr84985.c: New. + 2018-03-29 David Malcolm <dmalc...@redhat.com> PR c++/85110 Index: lra-constraints.c =================================================================== --- lra-constraints.c (revision 258820) +++ lra-constraints.c (working copy) @@ -2126,7 +2126,6 @@ process_alt_operands (int only_alternati && curr_operand_mode[m] != curr_operand_mode[nop]) break; - this_alternative_matches = m; m_hregno = get_hard_regno (*curr_id->operand_loc[m], false); /* We are supposed to match a previous operand. If we do, we win if that one did. If we do @@ -2228,6 +2227,7 @@ process_alt_operands (int only_alternati else did_match = true; + this_alternative_matches = m; /* This can be fixed with reloads if the operand we are supposed to match can be fixed with reloads. */ Index: testsuite/gcc.target/i386/pr84985.c =================================================================== --- testsuite/gcc.target/i386/pr84985.c (nonexistent) +++ testsuite/gcc.target/i386/pr84985.c (working copy) @@ -0,0 +1,6 @@ +/* { dg-do compile } */ +/* { dg-options "-O0" } */ +int main() { + int a; + asm("" : "=d"(a) : "0"(a), "0ae"(&a)); +}