Merged variable updates under the same condition. It reduces branch. In n1sdp, there is no performance improvement with this patch. In x86, there is also no performance improvement.
Suggested-by: Honnappa Nagarahalli <honnappa.nagaraha...@arm.com> Signed-off-by: Feifei Wang <feifei.wa...@arm.com> Reviewed-by: Ruifeng Wang <ruifeng.w...@arm.com> --- drivers/net/i40e/i40e_rxtx_vec_neon.c | 9 +++++---- drivers/net/i40e/i40e_rxtx_vec_sse.c | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/net/i40e/i40e_rxtx_vec_neon.c b/drivers/net/i40e/i40e_rxtx_vec_neon.c index b951ea2dc3..c7e4222b61 100644 --- a/drivers/net/i40e/i40e_rxtx_vec_neon.c +++ b/drivers/net/i40e/i40e_rxtx_vec_neon.c @@ -64,14 +64,15 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq) } rxq->rxrearm_start += RTE_I40E_RXQ_REARM_THRESH; - if (rxq->rxrearm_start >= rxq->nb_rx_desc) + rx_id = rxq->rxrearm_start - 1; + + if (unlikely(rxq->rxrearm_start >= rxq->nb_rx_desc)) { rxq->rxrearm_start = 0; + rx_id = rxq->nb_rx_desc - 1; + } rxq->rxrearm_nb -= RTE_I40E_RXQ_REARM_THRESH; - rx_id = (uint16_t)((rxq->rxrearm_start == 0) ? - (rxq->nb_rx_desc - 1) : (rxq->rxrearm_start - 1)); - rte_io_wmb(); /* Update the tail pointer on the NIC */ I40E_PCI_REG_WRITE_RELAXED(rxq->qrx_tail, rx_id); diff --git a/drivers/net/i40e/i40e_rxtx_vec_sse.c b/drivers/net/i40e/i40e_rxtx_vec_sse.c index 497b2404c6..0910039d69 100644 --- a/drivers/net/i40e/i40e_rxtx_vec_sse.c +++ b/drivers/net/i40e/i40e_rxtx_vec_sse.c @@ -77,14 +77,15 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq) } rxq->rxrearm_start += RTE_I40E_RXQ_REARM_THRESH; - if (rxq->rxrearm_start >= rxq->nb_rx_desc) + rx_id = rxq->rxrearm_start - 1; + + if (unlikely(rxq->rxrearm_start >= rxq->nb_rx_desc)) { rxq->rxrearm_start = 0; + rx_id = rxq->nb_rx_desc - 1; + } rxq->rxrearm_nb -= RTE_I40E_RXQ_REARM_THRESH; - rx_id = (uint16_t)((rxq->rxrearm_start == 0) ? - (rxq->nb_rx_desc - 1) : (rxq->rxrearm_start - 1)); - /* Update the tail pointer on the NIC */ I40E_PCI_REG_WC_WRITE(rxq->qrx_tail, rx_id); } -- 2.25.1