From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f193.google.com (mail-pf0-f193.google.com [209.85.192.193]) by dpdk.org (Postfix) with ESMTP id 049407CCD for ; Fri, 2 Jun 2017 07:08:00 +0200 (CEST) Received: by mail-pf0-f193.google.com with SMTP id n23so11176128pfb.3 for ; Thu, 01 Jun 2017 22:07:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=gL8SUZd4GMZiNHSPBbMZh+0qYn7En2ikyGOCaQ/Xnf4=; b=VweFfhm8+Ihsn4ZUAT8A1sQXhlFmemb+i71/FbafTAJ8HC6ygKUTL7roGEE1ORV1Bp G4S1eCXcMedVkfHDJIvhoMaLHBjbJN38YaOjE8/m7nlCN+13qIoF5K1HuQpwwLUqZPv1 wjKeL1r7rpb+YDULO2TXIq7vWjUO9JXvtoyXAZFn6nKhW7ooO8igHfo6hYfHPM/xesTS 5dtsSvbY72pL4O5il1eajfy6QUpoZDPVHfBaoDTqd1cN3SLcKYFez9B1S2eB9MEJRGoc faO9p4tQveDHXk7NWhtIHj7kY53fX3/fCxBMj0aDrrgC6rNN/ReaBtNWaJfrSt37cvbg Supw== X-Gm-Message-State: AODbwcBJGfEUMm54Bu1cOJP9VugJQ3ZlAQhAdEiOTNqS5PCXW7W01vdi cFnHRRdzYES5Qyobi2A= X-Received: by 10.84.168.67 with SMTP id e61mr81123650plb.124.1496380079234; Thu, 01 Jun 2017 22:07:59 -0700 (PDT) Received: from pandaria.us-west-2.compute.internal (ec2-54-69-216-171.us-west-2.compute.amazonaws.com. [54.69.216.171]) by smtp.gmail.com with ESMTPSA id o29sm35068762pgc.27.2017.06.01.22.07.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 01 Jun 2017 22:07:58 -0700 (PDT) From: Sangjin Han To: bruce.richardson@intel.com Cc: dev@dpdk.org, Sangjin Han Date: Fri, 2 Jun 2017 05:07:46 +0000 Message-Id: <1496380066-28535-1-git-send-email-sangjin@eecs.berkeley.edu> X-Mailer: git-send-email 2.7.4 Subject: [dpdk-dev] [PATCH v2] lpm: fix build error on g++ with -O0 option X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Jun 2017 05:08:00 -0000 When rte_lpm.h is used on x86, -O0 option (no optimization at all) given to gcc causes a compile error like this: error: the last argument must be an 8-bit immediate i24 = _mm_srli_si128(i24, sizeof(uint64_t)); -O0 option is useful for debugging and code coverage measurement, but this error prevents DPDK programs from building. This patch replaces "sizeof(uint64_t)" with a constant literal "8" to work around the issue. The issue occurs on gcc/g++ versions from 4.8 to 5. Signed-off-by: Sangjin Han --- v2: * Added a comment * Updated the commit message: both gcc and g++ are affected. --- lib/librte_lpm/rte_lpm_sse.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/librte_lpm/rte_lpm_sse.h b/lib/librte_lpm/rte_lpm_sse.h index ef33c6a..7ab90b7 100644 --- a/lib/librte_lpm/rte_lpm_sse.h +++ b/lib/librte_lpm/rte_lpm_sse.h @@ -78,7 +78,9 @@ rte_lpm_lookupx4(const struct rte_lpm *lpm, xmm_t ip, uint32_t hop[4], /* extract values from tbl24[] */ idx = _mm_cvtsi128_si64(i24); - i24 = _mm_srli_si128(i24, sizeof(uint64_t)); + + /* With -O0 option, gcc 4.8 - 5.4 fails to fold sizeof() into a constant */ + i24 = _mm_srli_si128(i24, /* sizeof(uint64_t) */ 8); ptbl = (const uint32_t *)&lpm->tbl24[(uint32_t)idx]; tbl[0] = *ptbl; -- 2.7.4