https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97708
--- Comment #30 from Alexander Monakov <amonakov at gcc dot gnu.org> --- Asm operand binding should work by looking at bound lvalue: "c"(a) binds an lvalue so if 'a' is a register var the compiler must remember its associated register; "c"(a+0) binds an rvalue, so what kind of variable 'a' is is irrelevant. The way it should work internally is at gimplification time the compiler should produce an additional asm statement argument that stores the associated register names for each operand. For example. for register int a asm("%eax"); asm("" : "r"(a+0), "r"(a), "r"(0)); gcc could internally produce a string ",%eax," signifying that operand 1 is bound to %eax and operands 0 and 2 are not bound to any particular register. Then all passes up to IRA don't need to give any particular care for asm operands, and IRA can use the string to place operands in appropriate registers (and diagnose a mismatch). This is also the only proper way to fix PR 87984 as far as I can tell.