vlib: 512-bit SIMD version of vlib_buffer_free
[vpp.git] / src / vppinfra / vector / index_to_ptr.h
index 91de354..3985b75 100644 (file)
@@ -92,7 +92,7 @@ clib_index_to_ptr_u32 (u32 *indices, void *base, u8 shift, void **ptrs,
          indices += 16;
          n_elts -= 16;
        }
-      if (n_elts > 8)
+      if (n_elts >= 8)
        {
          b0 = u64x8_from_u32x8 (u32x8_load_unaligned (indices));
          u64x8_store_unaligned ((b0 << shift) + off, ptrs);
@@ -101,6 +101,9 @@ clib_index_to_ptr_u32 (u32 *indices, void *base, u8 shift, void **ptrs,
          n_elts -= 8;
        }
 
+      if (n_elts == 0)
+       return;
+
       b0 = u64x8_from_u32x8 (u32x8_load_unaligned (indices + n_elts - 8));
       u64x8_store_unaligned ((b0 << shift) + off, ptrs + n_elts - 8);
     }