Skip to content

Commit 04d3bf7

Browse files
committed
Use faster NEON any/all
1 parent 69bc17b commit 04d3bf7

File tree

4 files changed

+48
-20
lines changed

4 files changed

+48
-20
lines changed

Source/astcenc_vecmathlib_common_4.h

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,26 +32,6 @@
3232

3333
#include <cstdio>
3434

35-
// ============================================================================
36-
// vmask4 operators and functions
37-
// ============================================================================
38-
39-
/**
40-
* @brief True if any lanes are enabled, false otherwise.
41-
*/
42-
ASTCENC_SIMD_INLINE bool any(vmask4 a)
43-
{
44-
return mask(a) != 0;
45-
}
46-
47-
/**
48-
* @brief True if all lanes are enabled, false otherwise.
49-
*/
50-
ASTCENC_SIMD_INLINE bool all(vmask4 a)
51-
{
52-
return mask(a) == 0xF;
53-
}
54-
5535
// ============================================================================
5636
// vint4 operators and functions
5737
// ============================================================================

Source/astcenc_vecmathlib_neon_4.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,22 @@ ASTCENC_SIMD_INLINE unsigned int mask(vmask4 a)
411411
return vaddvq_u32(vshlq_u32(tmp, shift));
412412
}
413413

414+
/**
415+
* @brief True if any lanes are enabled, false otherwise.
416+
*/
417+
ASTCENC_SIMD_INLINE bool any(vmask4 a)
418+
{
419+
return vmaxvq_u32(a.m) != 0;
420+
}
421+
422+
/**
423+
* @brief True if all lanes are enabled, false otherwise.
424+
*/
425+
ASTCENC_SIMD_INLINE bool all(vmask4 a)
426+
{
427+
return vminvq_u32(a.m) != 0;
428+
}
429+
414430
// ============================================================================
415431
// vint4 operators and functions
416432
// ============================================================================

Source/astcenc_vecmathlib_none_4.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,22 @@ ASTCENC_SIMD_INLINE unsigned int mask(vmask4 a)
418418
((a.m[3] >> 28) & 0x8);
419419
}
420420

421+
/**
422+
* @brief True if any lanes are enabled, false otherwise.
423+
*/
424+
ASTCENC_SIMD_INLINE bool any(vmask4 a)
425+
{
426+
return mask(a) != 0;
427+
}
428+
429+
/**
430+
* @brief True if all lanes are enabled, false otherwise.
431+
*/
432+
ASTCENC_SIMD_INLINE bool all(vmask4 a)
433+
{
434+
return mask(a) == 0xF;
435+
}
436+
421437
// ============================================================================
422438
// vint4 operators and functions
423439
// ============================================================================

Source/astcenc_vecmathlib_sse_4.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,22 @@ ASTCENC_SIMD_INLINE unsigned int mask(vmask4 a)
428428
return static_cast<unsigned int>(_mm_movemask_ps(a.m));
429429
}
430430

431+
/**
432+
* @brief True if any lanes are enabled, false otherwise.
433+
*/
434+
ASTCENC_SIMD_INLINE bool any(vmask4 a)
435+
{
436+
return mask(a) != 0;
437+
}
438+
439+
/**
440+
* @brief True if all lanes are enabled, false otherwise.
441+
*/
442+
ASTCENC_SIMD_INLINE bool all(vmask4 a)
443+
{
444+
return mask(a) == 0xF;
445+
}
446+
431447
// ============================================================================
432448
// vint4 operators and functions
433449
// ============================================================================

0 commit comments

Comments
 (0)