Converting addc to adcx

Segher Boessenkool segher@kernel.crashing.org
Fri May 31 11:19:00 GMT 2019


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).


Segher



More information about the Gcc-help mailing list