diff --git a/src/vlib/buffer_funcs.c b/src/vlib/buffer_funcs.c
index fcef2d8..9ed1bac 100644
--- a/src/vlib/buffer_funcs.c
+++ b/src/vlib/buffer_funcs.c
@@ -6,123 +6,12 @@
 #include <vlib/vlib.h>
 #include <vppinfra/vector_funcs.h>
 
-typedef struct
-{
-  uword used_elts[VLIB_FRAME_SIZE / 64];
-  u32 uword_offset;
-} extract_data_t;
-
-static_always_inline u32 *
-extract_unused_elts_x64 (u32 *elts, u16 *indices, u16 index, int n_left,
-			 u64 *bmp, u32 *dst)
-{
-  u64 mask = 0;
-#if defined(CLIB_HAVE_VEC128)
-  mask = clib_compare_u16_x64 (index, indices);
-  if (n_left == 64)
-    {
-      if (mask == ~0ULL)
-	{
-	  clib_memcpy_u32 (dst, elts, 64);
-	  *bmp = ~0ULL;
-	  return dst + 64;
-	}
-    }
-  else
-    mask &= pow2_mask (n_left);
-
-  *bmp |= mask;
-
-#if defined(CLIB_HAVE_VEC512_COMPRESS)
-  u32x16u *ev = (u32x16u *) elts;
-  for (int i = 0; i < 4; i++)
-    {
-      int cnt = _popcnt32 ((u16) mask);
-      u32x16_compress_store (ev[i], mask, dst);
-      dst += cnt;
-      mask >>= 16;
-    }
-
-#elif defined(CLIB_HAVE_VEC256_COMPRESS)
-  u32x8u *ev = (u32x8u *) elts;
-  for (int i = 0; i < 8; i++)
-    {
-      int cnt = _popcnt32 ((u8) mask);
-      u32x8_compress_store (ev[i], mask, dst);
-      dst += cnt;
-      mask >>= 8;
-    }
-#elif defined(CLIB_HAVE_VEC256)
-  while (mask)
-    {
-      u16 bit = count_trailing_zeros (mask);
-      mask = clear_lowest_set_bit (mask);
-      dst++[0] = elts[bit];
-    }
-#else
-  while (mask)
-    {
-      u16 bit = count_trailing_zeros (mask);
-      mask ^= 1ULL << bit;
-      dst++[0] = elts[bit];
-    }
-#endif
-#else
-  for (int i = 0; i < n_left; i++)
-    {
-      if (indices[i] == index)
-	{
-	  dst++[0] = elts[i];
-	  mask |= 1ULL << i;
-	}
-    }
-  *bmp |= mask;
-#endif
-  return dst;
-}
-
 static_always_inline u32
-extract_unused_elts_by_index (extract_data_t *d, u32 *elts, u16 *indices,
-			      u16 index, int n_left, u32 *dst)
-{
-  u32 *dst0 = dst;
-  u64 *bmp = d->used_elts;
-  while (n_left >= 64)
-    {
-      dst = extract_unused_elts_x64 (elts, indices, index, 64, bmp, dst);
-
-      /* next */
-      indices += 64;
-      elts += 64;
-      bmp++;
-      n_left -= 64;
-    }
-
-  if (n_left)
-    dst = extract_unused_elts_x64 (elts, indices, index, n_left, bmp, dst);
-
-  return dst - dst0;
-}
-
-static_always_inline u32
-find_first_unused_elt (extract_data_t *d)
-{
-  u64 *ue = d->used_elts + d->uword_offset;
-
-  while (PREDICT_FALSE (ue[0] == ~0))
-    {
-      ue++;
-      d->uword_offset++;
-    }
-
-  return d->uword_offset * 64 + count_trailing_zeros (~ue[0]);
-}
-
-static_always_inline u32
-enqueue_one (vlib_main_t *vm, vlib_node_runtime_t *node, extract_data_t *d,
+enqueue_one (vlib_main_t *vm, vlib_node_runtime_t *node, u64 *used_elt_bmp,
 	     u16 next_index, u32 *buffers, u16 *nexts, u32 n_buffers,
 	     u32 n_left, u32 *tmp)
 {
+  u64 match_bmp[VLIB_FRAME_SIZE / 64];
   vlib_frame_t *f;
   u32 n_extracted, n_free;
   u32 *to;
@@ -138,8 +27,12 @@
   else
     to = tmp;
 
-  n_extracted = extract_unused_elts_by_index (d, buffers, nexts, next_index,
-					      n_buffers, to);
+  clib_mask_compare_u16 (next_index, nexts, match_bmp, n_buffers);
+
+  n_extracted = clib_compress_u32 (to, buffers, match_bmp, n_buffers);
+
+  for (int i = 0; i < ARRAY_LEN (match_bmp); i++)
+    used_elt_bmp[i] |= match_bmp[i];
 
   if (to != tmp)
     {
@@ -183,18 +76,23 @@
 
   while (count >= VLIB_FRAME_SIZE)
     {
-      extract_data_t d = {};
+      u64 used_elt_bmp[VLIB_FRAME_SIZE / 64] = {};
       n_left = VLIB_FRAME_SIZE;
+      u32 off = 0;
 
       next_index = nexts[0];
-      n_left = enqueue_one (vm, node, &d, next_index, buffers, nexts,
+      n_left = enqueue_one (vm, node, used_elt_bmp, next_index, buffers, nexts,
 			    VLIB_FRAME_SIZE, n_left, tmp);
 
       while (n_left)
 	{
-	  next_index = nexts[find_first_unused_elt (&d)];
-	  n_left = enqueue_one (vm, node, &d, next_index, buffers, nexts,
-				VLIB_FRAME_SIZE, n_left, tmp);
+	  while (PREDICT_FALSE (used_elt_bmp[off] == ~0))
+	    off++;
+
+	  next_index =
+	    nexts[off * 64 + count_trailing_zeros (~used_elt_bmp[off])];
+	  n_left = enqueue_one (vm, node, used_elt_bmp, next_index, buffers,
+				nexts, VLIB_FRAME_SIZE, n_left, tmp);
 	}
 
       buffers += VLIB_FRAME_SIZE;
@@ -204,18 +102,23 @@
 
   if (count)
     {
-      extract_data_t d = {};
+      u64 used_elt_bmp[VLIB_FRAME_SIZE / 64] = {};
       next_index = nexts[0];
       n_left = count;
+      u32 off = 0;
 
-      n_left = enqueue_one (vm, node, &d, next_index, buffers, nexts, count,
-			    n_left, tmp);
+      n_left = enqueue_one (vm, node, used_elt_bmp, next_index, buffers, nexts,
+			    count, n_left, tmp);
 
       while (n_left)
 	{
-	  next_index = nexts[find_first_unused_elt (&d)];
-	  n_left = enqueue_one (vm, node, &d, next_index, buffers, nexts,
-				count, n_left, tmp);
+	  while (PREDICT_FALSE (used_elt_bmp[off] == ~0))
+	    off++;
+
+	  next_index =
+	    nexts[off * 64 + count_trailing_zeros (~used_elt_bmp[off])];
+	  n_left = enqueue_one (vm, node, used_elt_bmp, next_index, buffers,
+				nexts, count, n_left, tmp);
 	}
     }
 }
diff --git a/src/vppinfra/CMakeLists.txt b/src/vppinfra/CMakeLists.txt
index dd3690b..6da1fa2 100644
--- a/src/vppinfra/CMakeLists.txt
+++ b/src/vppinfra/CMakeLists.txt
@@ -261,4 +261,22 @@
       LINK_LIBRARIES vppinfra Threads::Threads
       )
   endforeach()
+
+set(test_files
+  test_vector_funcs_compress.c
+  test_vector_funcs_mask_compare.c
+)
+
+add_vpp_executable(test_vector_funcs
+  SOURCES
+  test_vector_funcs.c
+  ${test_files}
+  LINK_LIBRARIES vppinfra
+)
+
+vpp_library_set_multiarch_sources(test_vector_funcs
+  SOURCES
+  ${test_files}
+)
+
 endif(VPP_BUILD_VPPINFRA_TESTS)
diff --git a/src/vppinfra/cpu.c b/src/vppinfra/cpu.c
index d2edc61..045d1f7 100644
--- a/src/vppinfra/cpu.c
+++ b/src/vppinfra/cpu.c
@@ -238,6 +238,18 @@
   return node;
 }
 
+__clib_export u8 *
+format_march_variant (u8 *s, va_list *args)
+{
+  clib_march_variant_type_t t = va_arg (*args, clib_march_variant_type_t);
+  char *variants[] = { [0] = "default",
+#define _(s, n) [CLIB_MARCH_VARIANT_TYPE_##s] = n,
+		       foreach_march_variant
+#undef _
+  };
+  return format (s, "%s", variants[t]);
+}
+
 /*
  * fd.io coding-style-patch-verification: ON
  *
diff --git a/src/vppinfra/cpu.h b/src/vppinfra/cpu.h
index c770b9c..c1f2e9e 100644
--- a/src/vppinfra/cpu.h
+++ b/src/vppinfra/cpu.h
@@ -416,6 +416,7 @@
 format_function_t format_cpu_uarch;
 format_function_t format_cpu_model_name;
 format_function_t format_cpu_flags;
+format_function_t format_march_variant;
 
 /*
  * fd.io coding-style-patch-verification: ON
diff --git a/src/vppinfra/test_vector_funcs.c b/src/vppinfra/test_vector_funcs.c
new file mode 100644
index 0000000..85f159a
--- /dev/null
+++ b/src/vppinfra/test_vector_funcs.c
@@ -0,0 +1,42 @@
+/* SPDX-License-Identifier: Apache-2.0
+ * Copyright(c) 2021 Cisco Systems, Inc.
+ */
+
+#include <vppinfra/format.h>
+#include <vppinfra/test_vector_funcs.h>
+
+test_registration_t *test_registrations[CLIB_MARCH_TYPE_N_VARIANTS] = {};
+
+int
+main (int argc, char *argv[])
+{
+  clib_mem_init (0, 64ULL << 20);
+
+  for (int i = 0; i < CLIB_MARCH_TYPE_N_VARIANTS; i++)
+    {
+      test_registration_t *r = test_registrations[i];
+
+      if (r == 0)
+	continue;
+
+      fformat (stdout, "\nMultiarch Variant: %U\n", format_march_variant, i);
+      fformat (stdout,
+	       "-------------------------------------------------------\n");
+      while (r)
+	{
+	  clib_error_t *err;
+	  err = (r->fn) (0);
+	  fformat (stdout, "%-50s %s\n", r->name, err ? "FAIL" : "PASS");
+	  if (err)
+	    {
+	      clib_error_report (err);
+	      fformat (stdout, "\n");
+	    }
+
+	  r = r->next;
+	}
+    }
+
+  fformat (stdout, "\n");
+  return 0;
+}
diff --git a/src/vppinfra/test_vector_funcs.h b/src/vppinfra/test_vector_funcs.h
new file mode 100644
index 0000000..bc499fb
--- /dev/null
+++ b/src/vppinfra/test_vector_funcs.h
@@ -0,0 +1,35 @@
+/* SPDX-License-Identifier: Apache-2.0
+ * Copyright(c) 2021 Cisco Systems, Inc.
+ */
+
+#ifndef included_test_test_h
+#define included_test_test_h
+
+#include <vppinfra/cpu.h>
+
+typedef clib_error_t *(test_fn_t) (clib_error_t *);
+
+typedef struct test_registration_
+{
+  char *name;
+  u8 multiarch : 1;
+  test_fn_t *fn;
+  struct test_registration_ *next;
+} test_registration_t;
+
+extern test_registration_t *test_registrations[CLIB_MARCH_TYPE_N_VARIANTS];
+
+#define __clib_test_fn static __clib_noinline __clib_section (".test_wrapper")
+
+#define REGISTER_TEST(x)                                                      \
+  test_registration_t CLIB_MARCH_SFX (__test_##x);                            \
+  static void __clib_constructor CLIB_MARCH_SFX (__test_registration_##x) (   \
+    void)                                                                     \
+  {                                                                           \
+    test_registration_t *r = &CLIB_MARCH_SFX (__test_##x);                    \
+    r->next = test_registrations[CLIB_MARCH_SFX (CLIB_MARCH_VARIANT_TYPE)];   \
+    test_registrations[CLIB_MARCH_SFX (CLIB_MARCH_VARIANT_TYPE)] = r;         \
+  }                                                                           \
+  test_registration_t CLIB_MARCH_SFX (__test_##x)
+
+#endif
diff --git a/src/vppinfra/test_vector_funcs_compress.c b/src/vppinfra/test_vector_funcs_compress.c
new file mode 100644
index 0000000..c081560
--- /dev/null
+++ b/src/vppinfra/test_vector_funcs_compress.c
@@ -0,0 +1,81 @@
+/* SPDX-License-Identifier: Apache-2.0
+ * Copyright(c) 2021 Cisco Systems, Inc.
+ */
+
+#include <vppinfra/format.h>
+#include <vppinfra/vector_funcs.h>
+#include <vppinfra/test_vector_funcs.h>
+
+__clib_test_fn u32
+clib_compress_u32_wrapper (u32 *dst, u32 *src, u64 *mask, u32 n_elts)
+{
+  return clib_compress_u32 (dst, src, mask, n_elts);
+}
+
+typedef struct
+{
+  u64 mask[10];
+  u32 n_elts;
+} compress_test_t;
+
+static compress_test_t tests[] = {
+  { .mask = { 1 }, .n_elts = 1 },
+  { .mask = { 2 }, .n_elts = 2 },
+  { .mask = { 3 }, .n_elts = 2 },
+  { .mask = { 0, 1 }, .n_elts = 66 },
+  { .mask = { 0, 2 }, .n_elts = 69 },
+  { .mask = { 0, 3 }, .n_elts = 66 },
+  { .mask = { ~0ULL, ~0ULL, ~0ULL, ~0ULL }, .n_elts = 62 },
+  { .mask = { ~0ULL, ~0ULL, ~0ULL, ~0ULL }, .n_elts = 255 },
+  { .mask = { ~0ULL, 1, 1, ~0ULL }, .n_elts = 256 },
+};
+
+static clib_error_t *
+test_clib_compress_u32 (clib_error_t *err)
+{
+  u32 src[513];
+  u32 dst[513];
+  u32 i, j;
+
+  for (i = 0; i < ARRAY_LEN (src); i++)
+    src[i] = i;
+
+  for (i = 0; i < ARRAY_LEN (tests); i++)
+    {
+      compress_test_t *t = tests + i;
+      u32 *dp = dst;
+      u32 r;
+
+      for (j = 0; j < ARRAY_LEN (dst); j++)
+	dst[j] = 0xa5a5a5a5;
+
+      r = clib_compress_u32_wrapper (dst, src, t->mask, t->n_elts);
+
+      for (j = 0; j < t->n_elts; j++)
+	{
+	  if ((t->mask[j >> 6] & (1ULL << (j & 0x3f))) == 0)
+	    continue;
+
+	  if (dp[0] != src[j])
+	    return clib_error_return (err,
+				      "wrong data in testcase %u at "
+				      "(dst[%u] = 0x%x, src[%u] = 0x%x)",
+				      i, dp - dst, dp[0], j, src[j]);
+	  dp++;
+	}
+
+      if (dst[dp - dst + 1] != 0xa5a5a5a5)
+	return clib_error_return (err, "buffer overrun in testcase %u", i);
+
+      if (dp - dst != r)
+	return clib_error_return (err, "wrong number of elts in testcase %u",
+				  i);
+    }
+
+  return err;
+}
+
+REGISTER_TEST (clib_compress_u32) = {
+  .name = "clib_compress_u32",
+  .fn = test_clib_compress_u32,
+};
diff --git a/src/vppinfra/test_vector_funcs_mask_compare.c b/src/vppinfra/test_vector_funcs_mask_compare.c
new file mode 100644
index 0000000..009f877
--- /dev/null
+++ b/src/vppinfra/test_vector_funcs_mask_compare.c
@@ -0,0 +1,95 @@
+/* SPDX-License-Identifier: Apache-2.0
+ * Copyright(c) 2021 Cisco Systems, Inc.
+ */
+
+#include <vppinfra/format.h>
+#include <vppinfra/vector_funcs.h>
+#include <vppinfra/test_vector_funcs.h>
+
+__clib_test_fn void
+clib_mask_compare_u16_wrapper (u16 v, u16 *a, u64 *mask, u32 n_elts)
+{
+  clib_mask_compare_u16 (v, a, mask, n_elts);
+}
+
+__clib_test_fn void
+clib_mask_compare_u32_wrapper (u32 v, u32 *a, u64 *mask, u32 n_elts)
+{
+  clib_mask_compare_u32 (v, a, mask, n_elts);
+}
+
+static clib_error_t *
+test_clib_mask_compare_u16 (clib_error_t *err)
+{
+  u16 array[513];
+  u64 mask[10];
+  u32 i, j;
+
+  for (i = 0; i < ARRAY_LEN (array); i++)
+    array[i] = i;
+
+  for (i = 0; i < ARRAY_LEN (array); i++)
+    {
+      for (j = 0; j < ARRAY_LEN (mask); j++)
+	mask[j] = 0xa5a5a5a5a5a5a5a5;
+
+      clib_mask_compare_u16_wrapper (i, array, mask, i + 1);
+
+      for (j = 0; j < (i >> 6); j++)
+	{
+	  if (mask[j])
+	    return clib_error_return (err, "mask at position %u not zero", j);
+	}
+      if (mask[j] != 1ULL << (i & 0x3f))
+	return clib_error_return (err,
+				  "mask at position %u is %lx, expected %lx",
+				  j, mask[j], 1ULL << (i % 64));
+
+      if (mask[j + 1] != 0xa5a5a5a5a5a5a5a5)
+	return clib_error_return (err, "mask overrun at position %u", j + 1);
+    }
+  return err;
+}
+
+REGISTER_TEST (clib_mask_compare_u16) = {
+  .name = "clib_mask_compare_u16",
+  .fn = test_clib_mask_compare_u16,
+};
+
+static clib_error_t *
+test_clib_mask_compare_u32 (clib_error_t *err)
+{
+  u32 array[513];
+  u64 mask[10];
+  u32 i, j;
+
+  for (i = 0; i < ARRAY_LEN (array); i++)
+    array[i] = i;
+
+  for (i = 0; i < ARRAY_LEN (array); i++)
+    {
+      for (j = 0; j < ARRAY_LEN (mask); j++)
+	mask[j] = 0xa5a5a5a5a5a5a5a5;
+
+      clib_mask_compare_u32_wrapper (i, array, mask, i + 1);
+
+      for (j = 0; j < (i >> 6); j++)
+	{
+	  if (mask[j])
+	    return clib_error_return (err, "mask at position %u not zero", j);
+	}
+      if (mask[j] != 1ULL << (i & 0x3f))
+	return clib_error_return (err,
+				  "mask at position %u is %lx, expected %lx",
+				  j, mask[j], 1ULL << (i % 64));
+
+      if (mask[j + 1] != 0xa5a5a5a5a5a5a5a5)
+	return clib_error_return (err, "mask overrun at position %u", j + 1);
+    }
+  return err;
+}
+
+REGISTER_TEST (clib_mask_compare_u32) = {
+  .name = "clib_mask_compare_u32",
+  .fn = test_clib_mask_compare_u32,
+};
diff --git a/src/vppinfra/vector_funcs.h b/src/vppinfra/vector_funcs.h
index 5c446a5..fed1b5c 100644
--- a/src/vppinfra/vector_funcs.h
+++ b/src/vppinfra/vector_funcs.h
@@ -5,16 +5,10 @@
 #ifndef included_vector_funcs_h
 #define included_vector_funcs_h
 #include <vppinfra/clib.h>
-
-/** \brief Compare 64 16-bit elemments with provied value and return bitmap
-
-    @param v value to compare elements with
-    @param a array of 64 u16 elements
-    @return u64 bitmap where each bit represents result of comparison
-*/
+#include <vppinfra/memcpy.h>
 
 static_always_inline u64
-clib_compare_u16_x64 (u16 v, u16 *a)
+clib_mask_compare_u16_x64 (u16 v, u16 *a, u32 n_elts)
 {
   u64 mask = 0;
 #if defined(CLIB_HAVE_VEC512)
@@ -42,14 +36,9 @@
      of that bit represend element index. Finally vaddvq_u16() gives us sum
      of all elements of the vector which will give us u8 bitmap. */
 
-  mask = ((u64) vaddvq_u16 ((av[0] == v8) & m) |
-	  (u64) vaddvq_u16 ((av[1] == v8) & m) << 8 |
-	  (u64) vaddvq_u16 ((av[2] == v8) & m) << 16 |
-	  (u64) vaddvq_u16 ((av[3] == v8) & m) << 24 |
-	  (u64) vaddvq_u16 ((av[4] == v8) & m) << 32 |
-	  (u64) vaddvq_u16 ((av[5] == v8) & m) << 40 |
-	  (u64) vaddvq_u16 ((av[6] == v8) & m) << 48 |
-	  (u64) vaddvq_u16 ((av[7] == v8) & m) << 56);
+  for (int i = 0; i < 8; i++)
+    mask |= (u64) vaddvq_u16 ((av[i] == v8) & m) << (i * 8);
+
 #elif defined(CLIB_HAVE_VEC128) && defined(CLIB_HAVE_VEC128_MSB_MASK)
   u16x8 v8 = u16x8_splat (v);
   u16x8u *av = (u16x8u *) a;
@@ -58,11 +47,188 @@
 	  (u64) i8x16_msb_mask (i8x16_pack (v8 == av[4], v8 == av[5])) << 32 |
 	  (u64) i8x16_msb_mask (i8x16_pack (v8 == av[6], v8 == av[7])) << 48);
 #else
-  for (int i = 0; i < 64; i++)
+  for (int i = 0; i < n_elts; i++)
     if (a[i] == v)
       mask |= 1ULL << i;
 #endif
   return mask;
 }
 
+/** \brief Compare 16-bit elemments with provied value and return bitmap
+
+    @param v value to compare elements with
+    @param a array of u16 elements
+    @param mask array of u64 where reuslting mask will be stored
+    @param n_elts number of elements in the array
+    @return none
+*/
+
+static_always_inline void
+clib_mask_compare_u16 (u16 v, u16 *a, u64 *mask, u32 n_elts)
+{
+  while (n_elts >= 64)
+    {
+      mask++[0] = clib_mask_compare_u16_x64 (v, a, 64);
+      n_elts -= 64;
+      a += 64;
+    }
+
+  if (PREDICT_TRUE (n_elts == 0))
+    return;
+
+  mask[0] = clib_mask_compare_u16_x64 (v, a, n_elts) & pow2_mask (n_elts);
+}
+
+static_always_inline u64
+clib_mask_compare_u32_x64 (u32 v, u32 *a, u32 n_elts)
+{
+  u64 mask = 0;
+#if defined(CLIB_HAVE_VEC512)
+  u32x16 v16 = u32x16_splat (v);
+  u32x16u *av = (u32x16u *) a;
+  mask = ((u64) u32x16_is_equal_mask (av[0], v16) |
+	  (u64) u32x16_is_equal_mask (av[1], v16) << 16 |
+	  (u64) u32x16_is_equal_mask (av[2], v16) << 32 |
+	  (u64) u32x16_is_equal_mask (av[3], v16) << 48);
+#elif defined(CLIB_HAVE_VEC256)
+  u32x8 v8 = u32x8_splat (v);
+  u32x8u *av = (u32x8u *) a;
+  u32x8 m = { 0, 4, 1, 5, 2, 6, 3, 7 };
+  i8x32 c;
+
+  c = i8x32_pack (i16x16_pack ((i32x8) (v8 == av[0]), (i32x8) (v8 == av[1])),
+		  i16x16_pack ((i32x8) (v8 == av[2]), (i32x8) (v8 == av[3])));
+  mask = i8x32_msb_mask ((i8x32) u32x8_permute ((u32x8) c, m));
+
+  c = i8x32_pack (i16x16_pack ((i32x8) (v8 == av[4]), (i32x8) (v8 == av[5])),
+		  i16x16_pack ((i32x8) (v8 == av[6]), (i32x8) (v8 == av[7])));
+  mask |= (u64) i8x32_msb_mask ((i8x32) u32x8_permute ((u32x8) c, m)) << 32;
+
+#elif defined(CLIB_HAVE_VEC128) && defined(__ARM_NEON)
+  u32x4 v4 = u32x4_splat (v);
+  u32x4 m = { 1, 2, 4, 8 };
+  u32x4u *av = (u32x4u *) a;
+
+  /* compare each u32 elemment with v4, result gives -1 in each element
+     of the resulting vector if comparison result is true.
+     Bitwise AND with m will give us one bit set for true result and offset
+     of that bit represend element index. Finally vaddvq_u32() gives us sum
+     of all elements of the vector which will give us u8 bitmap. */
+
+  for (int i = 0; i < 16; i++)
+    mask |= (u64) vaddvq_u32 ((av[i] == v4) & m) << (i * 4);
+
+#elif defined(CLIB_HAVE_VEC128) && defined(CLIB_HAVE_VEC128_MSB_MASK)
+  u32x4 v4 = u32x4_splat (v);
+  u32x4u *av = (u32x4u *) a;
+
+  for (int i = 0; i < 4; i++)
+    {
+      i16x8 p1 = i16x8_pack (v4 == av[0], v4 == av[1]);
+      i16x8 p2 = i16x8_pack (v4 == av[2], v4 == av[3]);
+      mask |= (u64) i8x16_msb_mask (i8x16_pack (p1, p2)) << (i * 16);
+      av += 4;
+    }
+
+#else
+  for (int i = 0; i < n_elts; i++)
+    if (a[i] == v)
+      mask |= 1ULL << i;
+#endif
+  return mask;
+}
+
+/** \brief Compare 32-bit elemments with provied value and return bitmap
+
+    @param v value to compare elements with
+    @param a array of u32 elements
+    @param mask array of u64 where reuslting mask will be stored
+    @param n_elts number of elements in the array
+    @return none
+*/
+
+static_always_inline void
+clib_mask_compare_u32 (u32 v, u32 *a, u64 *bitmap, u32 n_elts)
+{
+  while (n_elts >= 64)
+    {
+      bitmap++[0] = clib_mask_compare_u32_x64 (v, a, 64);
+      n_elts -= 64;
+      a += 64;
+    }
+
+  if (PREDICT_TRUE (n_elts == 0))
+    return;
+
+  bitmap[0] = clib_mask_compare_u32_x64 (v, a, n_elts) & pow2_mask (n_elts);
+}
+
+static_always_inline u32 *
+clib_compress_u32_x64 (u32 *dst, u32 *src, u64 mask)
+{
+#if defined(CLIB_HAVE_VEC512_COMPRESS)
+  u32x16u *sv = (u32x16u *) src;
+  for (int i = 0; i < 4; i++)
+    {
+      int cnt = _popcnt32 ((u16) mask);
+      u32x16_compress_store (sv[i], mask, dst);
+      dst += cnt;
+      mask >>= 16;
+    }
+
+#elif defined(CLIB_HAVE_VEC256_COMPRESS)
+  u32x8u *sv = (u32x8u *) src;
+  for (int i = 0; i < 8; i++)
+    {
+      int cnt = _popcnt32 ((u8) mask);
+      u32x8_compress_store (sv[i], mask, dst);
+      dst += cnt;
+      mask >>= 8;
+    }
+#else
+  while (mask)
+    {
+      u16 bit = count_trailing_zeros (mask);
+      mask = clear_lowest_set_bit (mask);
+      dst++[0] = src[bit];
+    }
+#endif
+  return dst;
+}
+
+/** \brief Compare array of 32-bit elemments into destination array based on
+ * mask
+
+    @param dst destination array of u32 elements
+    @param src source array of u32 elements
+    @param mask array of u64 values representing compress mask
+    @param n_elts number of elements in the source array
+    @return number of elements stored in destionation array
+*/
+
+static_always_inline u32
+clib_compress_u32 (u32 *dst, u32 *src, u64 *mask, u32 n_elts)
+{
+  u32 *dst0 = dst;
+  while (n_elts >= 64)
+    {
+      if (mask[0] == ~0ULL)
+	{
+	  clib_memcpy_u32 (dst, src, 64);
+	  dst += 64;
+	}
+      else
+	dst = clib_compress_u32_x64 (dst, src, mask[0]);
+
+      mask++;
+      src += 64;
+      n_elts -= 64;
+    }
+
+  if (PREDICT_TRUE (n_elts == 0))
+    return dst - dst0;
+
+  return clib_compress_u32_x64 (dst, src, mask[0] & pow2_mask (n_elts)) - dst0;
+}
+
 #endif
