On the intrinsics reference site, the _subborrow_u64() intrinsic says it computes "b - a". But in both ICC and MSVC, the intrinsic does "a - b".
So the documentation contradicts what the intrinsic actually does in ICC and MSVC. Unfortunately, GCC's implementation of the intrinsic follows the documentation rather than ICC/MSVC's behavior. And this is causing a bit of a headache when porting some Windows code to Linux/GCC.
The following code prints 23 in ICC/MSVC. But it prints 18446744073709551593 in GCC. I don't know who's "right" or "wrong", but this inconsistency should probably be fixed.
#include <stdint.h> #include <iostream> using namespace std; #if __GNUC__ #include <x86intrin.h> #else #include <intrin.h> #endif int main(){ unsigned char carry = 0; uint64_t a = 123; uint64_t b = 100; uint64_t c; carry = _subborrow_u64(carry, a, b, (unsigned long long*)&c); cout << c << endl; system("pause"); }