From e01ce5ad5d93c2239d0885d4b9486ba10447a529 Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Thu, 10 Feb 2022 15:23:15 +0100 Subject: vppinfra:remove uXxY_is_greater not needed, '>' works... Type: improvement Change-Id: I9bfbac787e8dca24e9b1bceda0922740eed26346 Signed-off-by: Damjan Marion --- src/plugins/crypto_native/aes.h | 4 ++-- src/vppinfra/string.h | 12 ++++++------ src/vppinfra/vector_avx2.h | 6 ------ src/vppinfra/vector_neon.h | 6 ------ src/vppinfra/vector_sse42.h | 6 ------ 5 files changed, 8 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/plugins/crypto_native/aes.h b/src/plugins/crypto_native/aes.h index 0ba4e87af52..e7f840975d4 100644 --- a/src/plugins/crypto_native/aes.h +++ b/src/plugins/crypto_native/aes.h @@ -108,7 +108,7 @@ aes_block_store (u8 * p, u8x16 r) static_always_inline u8x16 aes_byte_mask (u8x16 x, u8 n_bytes) { - return x & u8x16_is_greater (u8x16_splat (n_bytes), byte_mask_scale); + return x & (u8x16_splat (n_bytes) > byte_mask_scale); } static_always_inline u8x16 @@ -132,7 +132,7 @@ aes_store_partial (void *p, u8x16 r, int n_bytes) #ifdef __AVX512F__ _mm_mask_storeu_epi8 (p, (1 << n_bytes) - 1, (__m128i) r); #else - u8x16 mask = u8x16_is_greater (u8x16_splat (n_bytes), byte_mask_scale); + u8x16 mask = u8x16_splat (n_bytes) > byte_mask_scale; _mm_maskmoveu_si128 ((__m128i) r, (__m128i) mask, p); #endif #endif diff --git a/src/vppinfra/string.h b/src/vppinfra/string.h index 758a541814d..8c5bea16393 100644 --- a/src/vppinfra/string.h +++ b/src/vppinfra/string.h @@ -232,14 +232,14 @@ clib_memcpy_le (u8 * dst, u8 * src, u8 len, u8 max_len) d0 = u8x32_load_unaligned (dst); d1 = u8x32_load_unaligned (dst + 32); - d0 = u8x32_blend (d0, s0, u8x32_is_greater (lv, mask)); + d0 = u8x32_blend (d0, s0, lv > mask); u8x32_store_unaligned (d0, dst); if (max_len <= 32) return; mask += add; - d1 = u8x32_blend (d1, s1, u8x32_is_greater (lv, mask)); + d1 = u8x32_blend (d1, s1, lv > mask); u8x32_store_unaligned (d1, dst + 32); #elif defined (CLIB_HAVE_VEC128) @@ -257,25 +257,25 @@ clib_memcpy_le (u8 * dst, u8 * src, u8 len, u8 max_len) d2 = u8x16_load_unaligned (dst + 32); d3 = u8x16_load_unaligned (dst + 48); - d0 = u8x16_blend (d0, s0, u8x16_is_greater (lv, mask)); + d0 = u8x16_blend (d0, s0, lv > mask); u8x16_store_unaligned (d0, dst); if (max_len <= 16) return; mask += add; - d1 = u8x16_blend (d1, s1, u8x16_is_greater (lv, mask)); + d1 = u8x16_blend (d1, s1, lv > mask); u8x16_store_unaligned (d1, dst + 16); if (max_len <= 32) return; mask += add; - d2 = u8x16_blend (d2, s2, u8x16_is_greater (lv, mask)); + d2 = u8x16_blend (d2, s2, lv > mask); u8x16_store_unaligned (d2, dst + 32); mask += add; - d3 = u8x16_blend (d3, s3, u8x16_is_greater (lv, mask)); + d3 = u8x16_blend (d3, s3, lv > mask); u8x16_store_unaligned (d3, dst + 48); #else memmove (dst, src, len); diff --git a/src/vppinfra/vector_avx2.h b/src/vppinfra/vector_avx2.h index 6a363ccfa92..f5c09a53f96 100644 --- a/src/vppinfra/vector_avx2.h +++ b/src/vppinfra/vector_avx2.h @@ -315,12 +315,6 @@ u32x8_scatter_one (u32x8 r, int index, void *p) *(u32 *) p = r[index]; } -static_always_inline u8x32 -u8x32_is_greater (u8x32 v1, u8x32 v2) -{ - return (u8x32) _mm256_cmpgt_epi8 ((__m256i) v1, (__m256i) v2); -} - static_always_inline u8x32 u8x32_blend (u8x32 v1, u8x32 v2, u8x32 mask) { diff --git a/src/vppinfra/vector_neon.h b/src/vppinfra/vector_neon.h index e7b31259f73..568b689c234 100644 --- a/src/vppinfra/vector_neon.h +++ b/src/vppinfra/vector_neon.h @@ -88,12 +88,6 @@ u8x16_compare_byte_mask (u8x16 v) return u8x16_compare_byte_mask (v); \ } \ \ - static_always_inline u##s##x##c t##s##x##c##_is_greater (t##s##x##c a, \ - t##s##x##c b) \ - { \ - return (u##s##x##c) vcgtq_##i (a, b); \ - } \ - \ static_always_inline t##s##x##c t##s##x##c##_add_saturate (t##s##x##c a, \ t##s##x##c b) \ { \ diff --git a/src/vppinfra/vector_sse42.h b/src/vppinfra/vector_sse42.h index 35495d6658f..2b8927b6920 100644 --- a/src/vppinfra/vector_sse42.h +++ b/src/vppinfra/vector_sse42.h @@ -477,12 +477,6 @@ u32x4_scatter_one (u32x4 r, int index, void *p) *(u32 *) p = r[index]; } -static_always_inline u8x16 -u8x16_is_greater (u8x16 v1, u8x16 v2) -{ - return (u8x16) _mm_cmpgt_epi8 ((__m128i) v1, (__m128i) v2); -} - static_always_inline u8x16 u8x16_blend (u8x16 v1, u8x16 v2, u8x16 mask) { -- cgit 1.2.3-korg