Community
cancel
Showing results for 
Search instead for 
Did you mean: 
AYee1
Novice
193 Views

Inconsistency between documentation and compiler for _subborrow_u64().

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");
}

 

0 Kudos
9 Replies
Kittur_G_Intel
Employee
193 Views

Thanks Alex, I'll look into this and update you accordingly and could be an issue in the doc, thanks.

Kittur

Kittur_G_Intel
Employee
193 Views

Hi Alex,
Thanks for bringing this to our attention, much appreciated.  Yes, the documentation needs to be fixed and apparently GCC too. I do find that the word description is correct in the doc but the formula is apparently not right.  I'll file an issue with the documentation team. I'll also  keep you updated as soon as the release with the fix is out - appreciate much.

Regards,
Kittur

 

Kittur_G_Intel
Employee
193 Views

Alex, the issue filed is DPD200410409 and will keep you updated as soon as the release with the fix is out, thanks.

Kittur

Michael_S_8
Beginner
193 Views

Please fix this page too.

https://software.intel.com/en-us/node/523869

It is also wrong but in different way.

 

 

Kittur_G_Intel
Employee
193 Views

Hi Michael,
Yes, will do. Thanks for letting me know and I've already passed on  that info as well to the doc team - appreciate much.
Kittur

Michael_S_8
Beginner
193 Views

One month later: nothing done.

You are not very quick, guys :(

 

Kittur_G_Intel
Employee
193 Views

Hi Michael,
Yes, I notice that it's not in the update 2 version :-( I've again pinged the doc team to find out as the issue is being addressed per notes in the tracker.  I'll update you as soon as I hear from the team.

Thanks,
Kittur 

Michael_S_8
Beginner
193 Views

3 months later: nothing done.

I am starting to suspect that it will never be fixed.

 

Michael_S_8
Beginner
193 Views

5 months later: Intel Intrinsics Guide is finally fixed.

I didn't check if the fix propagated to the latest gcc.

 

"Intel® C++ Compiler 17.0 Developer Guide and Reference" is correct.

https://software.intel.com/en-us/node/683526

 

"Intel® C++ Compiler 16.0 User and Reference Guide" is correct.

https://software.intel.com/en-us/node/694996

 

But "User and Reference Guide for the Intel® C++ Compiler 15.0" is still wrong.

https://software.intel.com/en-us/node/523869

 

Reply