Skip to content

Commit

Permalink
Use faster NEON any/all
Browse files Browse the repository at this point in the history
  • Loading branch information
solidpixel committed Jul 31, 2024
1 parent 69bc17b commit 04d3bf7
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 20 deletions.
20 changes: 0 additions & 20 deletions Source/astcenc_vecmathlib_common_4.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,6 @@

#include <cstdio>

// ============================================================================
// vmask4 operators and functions
// ============================================================================

/**
* @brief True if any lanes are enabled, false otherwise.
*/
ASTCENC_SIMD_INLINE bool any(vmask4 a)
{
return mask(a) != 0;
}

/**
* @brief True if all lanes are enabled, false otherwise.
*/
ASTCENC_SIMD_INLINE bool all(vmask4 a)
{
return mask(a) == 0xF;
}

// ============================================================================
// vint4 operators and functions
// ============================================================================
Expand Down
16 changes: 16 additions & 0 deletions Source/astcenc_vecmathlib_neon_4.h
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,22 @@ ASTCENC_SIMD_INLINE unsigned int mask(vmask4 a)
return vaddvq_u32(vshlq_u32(tmp, shift));
}

/**
* @brief True if any lanes are enabled, false otherwise.
*/
ASTCENC_SIMD_INLINE bool any(vmask4 a)
{
return vmaxvq_u32(a.m) != 0;
}

/**
* @brief True if all lanes are enabled, false otherwise.
*/
ASTCENC_SIMD_INLINE bool all(vmask4 a)
{
return vminvq_u32(a.m) != 0;
}

// ============================================================================
// vint4 operators and functions
// ============================================================================
Expand Down
16 changes: 16 additions & 0 deletions Source/astcenc_vecmathlib_none_4.h
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,22 @@ ASTCENC_SIMD_INLINE unsigned int mask(vmask4 a)
((a.m[3] >> 28) & 0x8);
}

/**
* @brief True if any lanes are enabled, false otherwise.
*/
ASTCENC_SIMD_INLINE bool any(vmask4 a)
{
return mask(a) != 0;
}

/**
* @brief True if all lanes are enabled, false otherwise.
*/
ASTCENC_SIMD_INLINE bool all(vmask4 a)
{
return mask(a) == 0xF;
}

// ============================================================================
// vint4 operators and functions
// ============================================================================
Expand Down
16 changes: 16 additions & 0 deletions Source/astcenc_vecmathlib_sse_4.h
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,22 @@ ASTCENC_SIMD_INLINE unsigned int mask(vmask4 a)
return static_cast<unsigned int>(_mm_movemask_ps(a.m));
}

/**
* @brief True if any lanes are enabled, false otherwise.
*/
ASTCENC_SIMD_INLINE bool any(vmask4 a)
{
return mask(a) != 0;
}

/**
* @brief True if all lanes are enabled, false otherwise.
*/
ASTCENC_SIMD_INLINE bool all(vmask4 a)
{
return mask(a) == 0xF;
}

// ============================================================================
// vint4 operators and functions
// ============================================================================
Expand Down

0 comments on commit 04d3bf7

Please sign in to comment.