Hi,
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?
Best regards,
Marcel
#include <immintrin.h>
#include <iostream>
using namespace std;
int main()
{
long res[2] = { 0, 0 };
long x[2] = { 1, 0 };
__asm__ volatile (
"add %2, %0 \n"
"adc %3, %1 \n"
: "+r"(res[0]), "+r"(res[1])
: "rm"(x[0]), "rm"(x[1])
: "cc"
);
cout << "res " << hex << res[0] << " " << res[1] << endl;
}