From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id AA78DA0555; Thu, 9 Jun 2022 14:17:19 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 80B9C427E9; Thu, 9 Jun 2022 14:17:14 +0200 (CEST) Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) by mails.dpdk.org (Postfix) with ESMTP id D2867406B4 for ; Thu, 9 Jun 2022 14:17:13 +0200 (CEST) Received: by mail-lj1-f177.google.com with SMTP id y29so25933791ljd.7 for ; Thu, 09 Jun 2022 05:17:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wXpXhR6pVCJLgcYGYWXmNmuOfSD4Vu5jMcpligv6DK8=; b=Yst37CBumRzsL71dzXMc1/eQ6kuaX7advg+hVHqs8fDvoS1Rtz4oHMWRTFAkqfOYvB UKKamW34I+lB42dYw/8i5kzuZXfZ9gJ/bVwrBN6YXAAJ1mOKCXdFfHzlBakRy1tZQ2wC KmeAAioMPhvqxMvieAF2QuTBSnXCpjHsL4mVERz+Npu9jpCguTHv/cAE0UnDHIf4IxLP fMybUKAGakxaCYUxTuAdP6uqWfIwgKnNFdZwhZFz/dKJQBGAObDB++qWZgm+DPyMfMc1 fe1S5M9giEN6F32mxrxYSMxCeU2Np1sE19aeI+JYTKKIHd3qiCZWSzUFvVdLFF4NHmnU Rqkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wXpXhR6pVCJLgcYGYWXmNmuOfSD4Vu5jMcpligv6DK8=; b=TC/oUL4ZsHTjJAuKdy2AHjNox/OuYmnxgR/ndZaVvq0iEPsgfOTmMmQPiR1oYZUHoz 52VEwrg/6UvEnzVBVGFGgyiR4jRzWC/NhWrRs07ObTxsyemuApo17Khz8aCXkgIVP/tT jsjCkr+oqjnZxRllFWaOg7rqDfl9/UsJHw/MxOkt4kkNMaMujcgQsZcufziDA/4XxXmO CgEjC2eQ8KS9+wx8JncpsgteKwp6zRaoaCrywOoBTubJHcyaK52UTG5YjJh5NtcEbvea FU2WrGy+/QaGXgovHEra3t57L0oMuduEkx8DSBT6vxTpEL5QjgTBK4YjQEOQM8bliJAF OMbg== X-Gm-Message-State: AOAM533lXjZhJRudeCv1MPOdzv166oUXU2V8WOO4vdepta9t/jJkmS9L agYOKksONn4z833Aj+GzDB+pQQ== X-Google-Smtp-Source: ABdhPJyYO7ofgpG2t6WczsCB9cqyUMqJHtOgYz/7ZUvs7WB1om/nlxAi93hXdxQTYw20AtjbO9WY0Q== X-Received: by 2002:a2e:b988:0:b0:255:75b6:91ff with SMTP id p8-20020a2eb988000000b0025575b691ffmr20398096ljp.228.1654777033407; Thu, 09 Jun 2022 05:17:13 -0700 (PDT) Received: from toster.semihalf.net ([83.142.187.86]) by smtp.gmail.com with ESMTPSA id f6-20020a2eb5a6000000b00253da47cfbesm3706999ljn.80.2022.06.09.05.17.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 05:17:13 -0700 (PDT) From: Stanislaw Kardach To: Vladimir Medvedkin Cc: Stanislaw Kardach , David Marchand , dev@dpdk.org, upstream@semihalf.com Subject: [PATCH 2/3] lpm: fix xmm_t casting for C++ in scalar version Date: Thu, 9 Jun 2022 14:17:00 +0200 Message-Id: <20220609121701.716299-3-kda@semihalf.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220609121701.716299-1-kda@semihalf.com> References: <20220609121701.716299-1-kda@semihalf.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org rte_xmm_t is a union type which wraps around xmm_t and maps its contents to scalar structures. Since C++ has stricter type conversion rules than C, the rte_xmm_t::x has to be used instead of C-casting. The generated assembly is identical to the code without the fix (checked both on x86 and RISC-V). Signed-off-by: Stanislaw Kardach --- lib/lpm/rte_lpm_scalar.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/lpm/rte_lpm_scalar.h b/lib/lpm/rte_lpm_scalar.h index f0d9f37894..161b40ff80 100644 --- a/lib/lpm/rte_lpm_scalar.h +++ b/lib/lpm/rte_lpm_scalar.h @@ -15,18 +15,19 @@ extern "C" { static inline void rte_lpm_lookupx4(const struct rte_lpm *lpm, xmm_t ip, uint32_t hop[4], - uint32_t defv) + uint32_t defv) { + rte_xmm_t xip = { .x = ip }; uint32_t nh; int ret; - ret = rte_lpm_lookup(lpm, ((rte_xmm_t)ip).u32[0], &nh); + ret = rte_lpm_lookup(lpm, xip.u32[0], &nh); hop[0] = (ret == 0) ? nh : defv; - ret = rte_lpm_lookup(lpm, ((rte_xmm_t)ip).u32[1], &nh); + ret = rte_lpm_lookup(lpm, xip.u32[1], &nh); hop[1] = (ret == 0) ? nh : defv; - ret = rte_lpm_lookup(lpm, ((rte_xmm_t)ip).u32[2], &nh); + ret = rte_lpm_lookup(lpm, xip.u32[2], &nh); hop[2] = (ret == 0) ? nh : defv; - ret = rte_lpm_lookup(lpm, ((rte_xmm_t)ip).u32[3], &nh); + ret = rte_lpm_lookup(lpm, xip.u32[3], &nh); hop[3] = (ret == 0) ? nh : defv; } -- 2.30.2