支持英特尔C编译器中的+, - ,*,/和%的128位整数?

Dou*_*ple 14 c int128 icc

GCC和Clang具有128位整数运算的扩展__int128_t__uint128_t扩展.

我希望__m128i将使用于英特尔C编译器类似的东西,但(如果它甚至有可能),它看起来对我来说,我不得不写明确SSE2函数调用为了使用__m128i,而是采用"内置"运营商喜欢+,-,*,/,和%.我希望做这样的事情(这不起作用):

#if defined(__INTEL_COMPILER) && defined(__SSE2__)
  #include "xmmintrin.h"
  typedef __u128 uint128_t;
#elif defined (__GNUC__)
  typedef __uint128_t uint128_t;
#else
  #error For 128-bit arithmetic we need GCC or ICC, or uint128_t
#endif
Run Code Online (Sandbox Code Playgroud)

有没有与运营商的128位整数支持+,-,*,/,和%地方埋在ICC?

han*_*rak 10

从我所知,至少icc 13.0.1+支持__int128_t__uint128_t.由Matt Godbolt的Compiler Explorer提供:

__int128_t ai (__int128_t x, __int128_t y) {
  return x + y;
}

__int128_t mi (__int128_t x, __int128_t y) {
  return x * y;
}

__int128_t di (__int128_t x, __int128_t y) {
  return x / y;
}

__int128_t ri (__int128_t x, __int128_t y) {
  return x % y;
}
Run Code Online (Sandbox Code Playgroud)

编译为:

L__routine_start_ai_0:
ai:
        add       rdi, rdx                                      #2.14
        mov       rax, rdi                                      #2.14
        adc       rsi, rcx                                      #2.14
        mov       rdx, rsi                                      #2.14
        ret                                                     #2.14
L__routine_start_mi_1:
mi:
        mov       rax, rdi                                      #6.14
        imul      rsi, rdx                                      #6.14
        imul      rcx, rdi                                      #6.14
        mul       rdx                                           #6.14
        add       rsi, rcx                                      #6.14
        add       rdx, rsi                                      #6.14
        ret                                                     #6.14
L__routine_start_di_2:
di:
        push      rsi                                           #9.44
        call      __divti3                                      #10.14
        pop       rcx                                           #10.14
        ret                                                     #10.14
L__routine_start_ri_3:
ri:
        push      rsi                                           #13.44
        call      __modti3                                      #14.14
        pop       rcx                                           #14.14
        ret                                                     #14.14
Run Code Online (Sandbox Code Playgroud)

icc 13.0.1(http://goo.gl/UnxEFt).