Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

Missing GCC 5 builtin intrinsics for math with carry

olzhas_r_
New Contributor I
873 Views
0 Kudos
1 Solution
Varsha_M_Intel
Employee
873 Views

I was able to reproduce the issue and have escalated to the engineer.

View solution in original post

0 Kudos
9 Replies
Varsha_M_Intel
Employee
873 Views

Hi ,
Could you provide us a sample code snippet to reproduce this issue?

Thanks,
Varsha

0 Kudos
olzhas_r_
New Contributor I
873 Views
0 Kudos
Varsha_M_Intel
Employee
874 Views

I was able to reproduce the issue and have escalated to the engineer.

0 Kudos
nemequ
New Contributor I
873 Views

This should be fixed (assuming __GNUC__ >= 5), but if you need something portable in the meantime see https://github.com/nemequ/safe-math (it assumes those builtins are available if __GNUC__ >= 5, but it would be trivial to add an exception for ICC, or you could just define SAFE_FORCE_PORTABLE before including the header).

0 Kudos
olzhas_r_
New Contributor I
873 Views

Hi Evan, nice to see you here! I posted your solution and this forum into gnome issue.

0 Kudos
THIAGO_M_Intel1
Employee
873 Views

Note that ICC does have intrinsics that are much older than GCC's and Clang's. They are the same as MSVC's: _addcarry_u32 and _addcarry_u64 (see https://software.intel.com/en-us/node/523867), as I noted in the bug report.

0 Kudos
nemequ
New Contributor I
873 Views

THIAGO M. (Intel) wrote:
Note that ICC does have intrinsics that are much older than GCC's and Clang's. They are the same as MSVC's: _addcarry_u32 and _addcarry_u64 (see https://software.intel.com/en-us/node/523867), as I noted in the bug report.

That's useful (and I'll add those to my safe math header as soon as I have time), but I think the point is that if ICC is going to masquerade as a version of GCC it should support all the builtins, attributes, etc., that that version of GCC supports.  If that's not possible, it should stick to masquerading as an older version of GCC (clang 3.8 masquerades as GCC 4.2.1), but add support for clang's __has_{attribute,warning,feature,builtin} macros for more advanced functionality.

Also, note that GCC's intrinsics support addition, subtraction, and multiplication, whereas ICC (AFAICT) only supports addition.

Finally, GCC has type-generic versions (__builtin_{add,sub,mul}_overflow).

0 Kudos
olzhas_r_
New Contributor I
873 Views

Still missing in the new icc 17.

0 Kudos
olzhas_r_
New Contributor I
873 Views

Looks fixed in icc 17.0.1.

Thanks!

0 Kudos
Reply