On Fri, May 31, 2019 at 07:29:43AM -0400, Jeffrey Walton wrote: > On Fri, May 31, 2019 at 7:19 AM Segher Boessenkool > <segher@xxxxxxxxxxxxxxxxxxx> wrote: > > > > On Fri, May 31, 2019 at 06:34:19AM -0400, Jeffrey Walton wrote: > > > We have this inline asm on x86_64. Notice adcq and the constant $0: > > > > > > asm ("addq %2, %0; adcq $0, %1;" : "+r"(a0), "+r"(a1) : "r"(b) : "cc"); > > > > > > I convert it to adcx. This conversion tests OK. > > > > > > asm ("addq %2, %0; adcx %3, %1;" : "+r"(a0), "+r"(a1) : "r"(b), > > > "r"(0ULL) : "cc"); > > > > > > Is this a valid conversion? > > > > Writing to %0 can clobber %3, the way you wrote it. Use an earlyclobber? > > > > (Look at the generated code to see what is happening -- use -S instead of -c > > for example). > > Man, it did not like that when using "&=r"(0ULL) (hundreds of them): > > error: lvalue required in asm statement > > (I assume you wanted an early clobber on the input %3). You are saying there that you want to output to something that is constant 0. Yeah that doesn't work ;-) You should put the earlyclobber on the output, to tell GCC that that output (register) is clobbered early, i.e. before all inputs are used (so that GCC then knows to not put that output in the same place as one of the inputs). Like so: asm ("addq %2, %0; adcx %3, %1;" : "+&r"(a0), "+r"(a1) : "r"(b), "r"(0ULL) : "cc"); Segher