1

I am trying to use _BitScanForward64 intrinsic (https://software.intel.com/sites/landingpage/IntrinsicsGuide/#expand=381,421,373&cats=Bit%20Manipulation) using MinGW 64 on Windows (GCC 4.8.1).

I tried:

#include "immintrin.h"
#include "x86intrin.h"
#include "xmmintrin.h"

but it still doesn't see the function (according to Intel guide it should be in "immintrin.h").

How do I get it to work using MinGW64 on Windows?

Piotr Lopusiewicz
  • 2,514
  • 2
  • 27
  • 38
  • The Intel compiler can be used in Visual Studio. They support some intrinsic which Microsoft uses but not GCC. GCC has built in functions for this. Search around and you will find them. https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html – Z boson Oct 21 '15 at 08:58

1 Answers1

1

GCC does not use a intrinsic for this. It uses a built in function _builtin_ffs. Wikipedia has a nice summary for each compiler.

The reason Intel lists this intrinsic I think is that the Intel C++ compilers tries to support the same intrinsics which Microsoft created at least when used in Visual Studio on Windows. This unfortunately means that some intrinsics are not defined for each compiler. Even worse is that sometimes they are defined differently. For example Intel's definition of addcarry-u64 disagrees with Microsoft's definition but looking at the assembly shows that Intel uses Microsoft's definition and GCC and Clang use Intel's defintion.

For most x86 SIMD intrinsics GCC, Intel, Clang, and MSVC agree (with a few exceptions coming from MSVC) but for other intrinsics you have to get used to them being only defined in some compilers or being defined differently or having to use builtin functions or a library function.

The Intel compiler even has it's own intrinsics for this: _bit_scan_forward.

Community
  • 1
  • 1
Z boson
  • 32,619
  • 11
  • 123
  • 226