【问题标题】:_BitScanForward64 using MinGW on Windows_BitScanForward64 在 Windows 上使用 MinGW
【发布时间】:2015-10-20 19:43:11
【问题描述】:

我正在尝试在 Windows (GCC 4.8.1) 上使用 MinGW 64 使用 _BitScanForward64 内在 (https://software.intel.com/sites/landingpage/IntrinsicsGuide/#expand=381,421,373&cats=Bit%20Manipulation)。

我试过了:

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

但它仍然看不到该功能(根据英特尔指南,它应该在“immintrin.h”中)。

如何在 Windows 上使用 MinGW64 让它工作?

【问题讨论】:

标签: c windows gcc intrinsics mingw-w64


【解决方案1】:

GCC 不为此使用内在函数。它使用built in function_builtin_ffs。维基百科的每个编译器都有一个nice summary

我认为英特尔列出这个内在函数的原因是英特尔 C++ 编译器试图支持与 Microsoft created 相同的内在函数,至少在 Windows 上的 Visual Studio 中使用时。不幸的是,这意味着没有为每个编译器定义一些内在函数。更糟糕的是,有时它们的定义不同。例如英特尔对addcarry-u64 的定义与微软的定义不一致,但looking at the assembly shows that Intel uses Microsoft's definition and GCC and Clang use Intel's defintion

对于大多数 x86 SIMD 内部函数,GCC、英特尔、Clang 和 MSVC 都同意 (with a few exceptions coming from MSVC),但对于其他内部函数,您必须习惯它们仅在某些编译器中定义或以不同方式定义或必须使用内置函数或一个库函数。

英特尔编译器甚至为此拥有自己的内部函数:_bit_scan_forward

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-01-16
    • 2012-01-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-26
    相关资源
    最近更新 更多