Check compiler architecture flags in one place

This commit is contained in:
Matthew Barr
2017-03-29 16:39:16 +11:00
parent 5fe524fbb3
commit 8201183138
31 changed files with 203 additions and 109 deletions

View File

@@ -35,6 +35,7 @@
#include "ue2common.h"
#include "popcount.h"
#include "util/arch.h"
#ifdef __cplusplus
# if defined(HAVE_CXX_X86INTRIN_H)
@@ -269,7 +270,7 @@ u32 findAndClearMSB_64(u64a *v) {
static really_inline
u32 compress32(u32 x, u32 m) {
#if defined(__BMI2__)
#if defined(HAVE_BMI2)
// BMI2 has a single instruction for this operation.
return _pext_u32(x, m);
#else
@@ -304,7 +305,7 @@ u32 compress32(u32 x, u32 m) {
static really_inline
u64a compress64(u64a x, u64a m) {
#if defined(ARCH_X86_64) && defined(__BMI2__)
#if defined(ARCH_X86_64) && defined(HAVE_BMI2)
// BMI2 has a single instruction for this operation.
return _pext_u64(x, m);
#else
@@ -340,7 +341,7 @@ u64a compress64(u64a x, u64a m) {
static really_inline
u32 expand32(u32 x, u32 m) {
#if defined(__BMI2__)
#if defined(HAVE_BMI2)
// BMI2 has a single instruction for this operation.
return _pdep_u32(x, m);
#else
@@ -380,7 +381,7 @@ u32 expand32(u32 x, u32 m) {
static really_inline
u64a expand64(u64a x, u64a m) {
#if defined(ARCH_X86_64) && defined(__BMI2__)
#if defined(ARCH_X86_64) && defined(HAVE_BMI2)
// BMI2 has a single instruction for this operation.
return _pdep_u64(x, m);
#else
@@ -471,14 +472,9 @@ u32 rank_in_mask64(u64a mask, u32 bit) {
return popcount64(mask);
}
#if defined(__BMI2__) || (defined(_WIN32) && defined(__AVX2__)) || \
(defined(__INTEL_COMPILER) && defined(__AVX2__))
#define HAVE_PEXT
#endif
static really_inline
u32 pext32(u32 x, u32 mask) {
#if defined(HAVE_PEXT)
#if defined(HAVE_BMI2)
// Intel BMI2 can do this operation in one instruction.
return _pext_u32(x, mask);
#else
@@ -498,7 +494,7 @@ u32 pext32(u32 x, u32 mask) {
static really_inline
u64a pext64(u64a x, u64a mask) {
#if defined(HAVE_PEXT) && defined(ARCH_64_BIT)
#if defined(HAVE_BMI2) && defined(ARCH_64_BIT)
// Intel BMI2 can do this operation in one instruction.
return _pext_u64(x, mask);
#else
@@ -516,7 +512,7 @@ u64a pext64(u64a x, u64a mask) {
#endif
}
#if defined(HAVE_PEXT) && defined(ARCH_64_BIT)
#if defined(HAVE_BMI2) && defined(ARCH_64_BIT)
static really_inline
u64a pdep64(u64a x, u64a mask) {
return _pdep_u64(x, mask);