The following code produces different output between ICC16.2 and GCC5.3.
#include <stdint.h> #include <stdlib.h> #include <iostream> using namespace std; int main(){ uint64_t a = 123456789123456789; uint64_t b = 987654321987654321; uint64_t L, H; __asm__( "mulx %[a], %[L], %[H];" : [L] "=r" (L), [H] "=r" (H) : [a] "r" (a), [b] "d" (b) ); cout << "low = "<< L << endl; cout << "high = "<< H << endl; system("pause"); }
On Windows/ICC16, it outputs:
low = 6609981190679600
high = 14369616054794401669
On Linux/GCC5.3, it outputs:
low = 14369616054794401669
high = 6609981190679600
The order of the output operands on the MULX instruction are swapped. I believe GCC is correct since the inline assembly maps 1-to-1 to the AT&T GCC syntax, whereas ICC converts it to Intel syntax and in the process switches the order of the operands.