All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] lpm: fix build error on g++ with -O0 option
@ 2017-06-02  5:07 Sangjin Han
  2017-06-02  9:30 ` Bruce Richardson
  0 siblings, 1 reply; 3+ messages in thread
From: Sangjin Han @ 2017-06-02  5:07 UTC (permalink / raw)
  To: bruce.richardson; +Cc: dev, Sangjin Han

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 <sangjin@eecs.berkeley.edu>

---

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] lpm: fix build error on g++ with -O0 option
  2017-06-02  5:07 [PATCH v2] lpm: fix build error on g++ with -O0 option Sangjin Han
@ 2017-06-02  9:30 ` Bruce Richardson
  2017-06-05 13:12   ` Thomas Monjalon
  0 siblings, 1 reply; 3+ messages in thread
From: Bruce Richardson @ 2017-06-02  9:30 UTC (permalink / raw)
  To: Sangjin Han; +Cc: dev

On Fri, Jun 02, 2017 at 05:07:46AM +0000, Sangjin Han wrote:
> 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 <sangjin@eecs.berkeley.edu>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] lpm: fix build error on g++ with -O0 option
  2017-06-02  9:30 ` Bruce Richardson
@ 2017-06-05 13:12   ` Thomas Monjalon
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Monjalon @ 2017-06-05 13:12 UTC (permalink / raw)
  To: Sangjin Han; +Cc: dev, Bruce Richardson

02/06/2017 11:30, Bruce Richardson:
> On Fri, Jun 02, 2017 at 05:07:46AM +0000, Sangjin Han wrote:
> > 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 <sangjin@eecs.berkeley.edu>
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>

Applied (with indent fix), thanks

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-06-05 13:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-02  5:07 [PATCH v2] lpm: fix build error on g++ with -O0 option Sangjin Han
2017-06-02  9:30 ` Bruce Richardson
2017-06-05 13:12   ` Thomas Monjalon

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.