128-bit inline assembly addition

Marc Glisse marc.glisse@inria.fr
Mon Jul 16 21:48:00 GMT 2018


On Mon, 16 Jul 2018, Marcel Keller wrote:

> I've found that the attached program, which supposedly adds 1 and 0 as 
> 128-bit numbers using inline assembly, outputs 2^64 + 1 instead when compiled 
> with g++ 7 or 8 and at least -O1. Am I doing something wrong, or is this a 
> compiler bug?

I think the keyword is early-clobber. Try "+&r" for the first variable, 
which is overwritten in the first instruction, so gcc knows not to merge 
it with x[1].

-- 
Marc Glisse



More information about the Gcc-help mailing list