- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 %, %, % "r" (a), "d" (b) ); cout << "low = " << L << endl; cout << "high = " << H << endl; system("pause"); };" : "=r" (L), "=r" (H) :
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.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @a-yee,
I could reproduce on Windows/16.0.2. Can you let me know the OS info and the platform you're running on with Linux* as I couldn't on Linux*
Thanks,
Kittur
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Kittur,
The hardware is:
- Core i7 4770K (Haswell)
I've tested on two versions of Ubuntu/GCC. They both produce the same result - which is different from what ICC 16.02 produces on Windows.
- Ubuntu 15.10
- GCC 5.3.0
- Compile as: "g++ mulx.cpp" (no other compiler options)
and
- Ubuntu 16.04
- GCC 5.3.1
- Compile as: "g++ mulx.cpp" (no other compiler options)
The Ubuntu 16.04 is freshly installed out-of-the box from one of the recent ISOs.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Alex,
Thanks, yes I could reproduce the issue and will file the issue with the developers and update you accordingly - appreciate much.
Kittur

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page