Remove unneeded code at preproc stage

If we know we have BMI2 we shouldn't produce the fallback code.
This commit is contained in:
Matthew Barr 2015-10-30 10:43:43 +11:00
parent aafbd96a1d
commit 1f47b82106
2 changed files with 12 additions and 6 deletions

View File

@ -254,7 +254,7 @@ u32 compress32(u32 x, u32 m) {
#if defined(__BMI2__)
// BMI2 has a single instruction for this operation.
return _pext_u32(x, m);
#endif
#else
// Return zero quickly on trivial cases
if ((x & m) == 0) {
@ -281,6 +281,7 @@ u32 compress32(u32 x, u32 m) {
}
return x;
#endif
}
static really_inline
@ -288,7 +289,7 @@ u64a compress64(u64a x, u64a m) {
#if defined(ARCH_X86_64) && defined(__BMI2__)
// BMI2 has a single instruction for this operation.
return _pext_u64(x, m);
#endif
#else
// Return zero quickly on trivial cases
if ((x & m) == 0) {
@ -316,6 +317,7 @@ u64a compress64(u64a x, u64a m) {
}
return x;
#endif
}
static really_inline
@ -323,7 +325,7 @@ u32 expand32(u32 x, u32 m) {
#if defined(__BMI2__)
// BMI2 has a single instruction for this operation.
return _pdep_u32(x, m);
#endif
#else
// Return zero quickly on trivial cases
if (!x || !m) {
@ -355,6 +357,7 @@ u32 expand32(u32 x, u32 m) {
}
return x & m0; // clear out extraneous bits
#endif
}
static really_inline
@ -362,7 +365,7 @@ u64a expand64(u64a x, u64a m) {
#if defined(ARCH_X86_64) && defined(__BMI2__)
// BMI2 has a single instruction for this operation.
return _pdep_u64(x, m);
#endif
#else
// Return zero quickly on trivial cases
if (!x || !m) {
@ -395,6 +398,7 @@ u64a expand64(u64a x, u64a m) {
}
return x & m0; // clear out extraneous bits
#endif
}

View File

@ -51,7 +51,7 @@ u32 shuffleDynamic32(u32 x, u32 mask) {
#if defined(HAVE_PEXT)
// Intel BMI2 can do this operation in one instruction.
return _pext_u32(x, mask);
#endif
#else
u32 result = 0, num = 1;
while (mask != 0) {
@ -63,6 +63,7 @@ u32 shuffleDynamic32(u32 x, u32 mask) {
num <<= 1;
}
return result;
#endif
}
static really_inline
@ -70,7 +71,7 @@ u32 shuffleDynamic64(u64a x, u64a mask) {
#if defined(HAVE_PEXT) && defined(ARCH_64_BIT)
// Intel BMI2 can do this operation in one instruction.
return _pext_u64(x, mask);
#endif
#else
u32 result = 0, num = 1;
while (mask != 0) {
@ -82,6 +83,7 @@ u32 shuffleDynamic64(u64a x, u64a mask) {
num <<= 1;
}
return result;
#endif
}
#undef HAVE_PEXT