diff options
author | Damjan Marion <damarion@cisco.com> | 2018-05-10 13:40:44 +0200 |
---|---|---|
committer | Dave Barach <openvpp@barachs.net> | 2018-05-10 17:16:56 +0000 |
commit | 1105600416e0560cb05120a22e0a2e7359a13665 (patch) | |
tree | acf1df08de42344c380473d81886864e662890cf /src/vnet/devices/virtio/vhost-user.c | |
parent | 132dc49ee847a3e3b644de8b36499d73e8a8d37e (diff) |
vppinfra: use count_trailing_zeros in sparse_vec_index
It is much cheaper to use ctzll than to do shift,subtract and mask
in likely case when we are looking for 1st set bit in the uword.
Change-Id: I31954081571978878c7098bafad0c85a91755fa2
Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vnet/devices/virtio/vhost-user.c')
-rw-r--r-- | src/vnet/devices/virtio/vhost-user.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/vnet/devices/virtio/vhost-user.c b/src/vnet/devices/virtio/vhost-user.c index c1fca441fa5..7e10a60f5fb 100644 --- a/src/vnet/devices/virtio/vhost-user.c +++ b/src/vnet/devices/virtio/vhost-user.c @@ -248,8 +248,8 @@ map_guest_mem (vhost_user_intf_t * vui, uword addr, u32 * hint) r = _mm_blend_epi16 (r, _mm_and_si128 (rl, rh), 0x88); r = _mm_shuffle_epi8 (r, _mm_set_epi64x (0, 0x0e060c040a020800)); - i = __builtin_ctzll (_mm_movemask_epi8 (r) | - (1 << VHOST_MEMORY_MAX_NREGIONS)); + i = count_trailing_zeros (_mm_movemask_epi8 (r) | + (1 << VHOST_MEMORY_MAX_NREGIONS)); if (i < vui->nregions) { @@ -275,7 +275,7 @@ map_guest_mem (vhost_user_intf_t * vui, uword addr, u32 * hint) if (u32) { - i = __builtin_ctzll (u32); + i = count_trailing_zeros (u32); goto vhost_map_guest_mem_done; } @@ -290,7 +290,7 @@ map_guest_mem (vhost_user_intf_t * vui, uword addr, u32 * hint) if (u32) { - i = __builtin_ctzll (u32); + i = count_trailing_zeros (u32); goto vhost_map_guest_mem_done; } @@ -305,7 +305,7 @@ map_guest_mem (vhost_user_intf_t * vui, uword addr, u32 * hint) if (u32) { - i = __builtin_ctzll (u32); + i = count_trailing_zeros (u32); goto vhost_map_guest_mem_done; } @@ -318,7 +318,7 @@ map_guest_mem (vhost_user_intf_t * vui, uword addr, u32 * hint) u32 |= ((vgetq_lane_u8 (vreinterpretq_u8_u64 (r), 0) & 0x1) << 6); u32 |= ((vgetq_lane_u8 (vreinterpretq_u8_u64 (r), 8) & 0x1) << 7); - i = __builtin_ctzll (u32 | (1 << VHOST_MEMORY_MAX_NREGIONS)); + i = count_trailing_zeros (u32 | (1 << VHOST_MEMORY_MAX_NREGIONS)); vhost_map_guest_mem_done: if (i < vui->nregions) |