https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120284
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Huiba Li from comment #3) > > Note the 0 there rather than r. r in the input means any register while 0 > > means it needs to match the same register as the 0th operand which in this > > case is the output operand. > > Thanks for your quick response. Using "0" does resolve the issue, as what > "+r" does. > > And actually, I don't need the input register to be the same as the output > register. All I need here is making x both input and output to the assembly. > So in theory, should it also be OK to write ```asm volatile("" : "=r"(x) : > "r"(x))```? > > BTW, the "+r" form and "0" form both produce code like this: > > ... > <+64>: movq %r15, %rax > <+67>: movq %rax, %r15 > vpbroadcastd (%rax), %zmm17 > ... > > This also looks sub-optimal. Marking x as an output without tieing it to another register will have garbage in the variable after the inline-asm. That is explicitly mentioned.