Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1369154

[RFC PATCH 2/6] ppc: bpf/jit: Optimize 64-bit Immediate loads

From "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>
Newsgroups linux.kernel
Subject [RFC PATCH 2/6] ppc: bpf/jit: Optimize 64-bit Immediate loads
Date 2016-04-01 12:10 +0200
Message-ID <rj4bF-2M5-33@gated-at.bofh.it> (permalink)
References <rj4bE-2M5-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Similar to the LI32() optimization, if the value can be represented
in 32-bits, use LI32(). Also handle loading a few specific forms of
immediate values in an optimum manner.

While at it, remove the semicolon at the end of the macro!

Cc: Matt Evans <matt@ozlabs.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Alexei Starovoitov <ast@fb.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
---
 arch/powerpc/net/bpf_jit.h | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/net/bpf_jit.h b/arch/powerpc/net/bpf_jit.h
index a9882db..4c1e055 100644
--- a/arch/powerpc/net/bpf_jit.h
+++ b/arch/powerpc/net/bpf_jit.h
@@ -244,20 +244,25 @@ DECLARE_LOAD_FUNC(sk_load_byte_msh);
 		} } while(0)
 
 #define PPC_LI64(d, i)		do {					      \
-		if (!((uintptr_t)(i) & 0xffffffff00000000ULL))		      \
+		if ((long)(i) >= -2147483648 &&				      \
+				(long)(i) < 2147483648)			      \
 			PPC_LI32(d, i);					      \
 		else {							      \
-			PPC_LIS(d, ((uintptr_t)(i) >> 48));		      \
-			if ((uintptr_t)(i) & 0x0000ffff00000000ULL)	      \
-				PPC_ORI(d, d,				      \
-					((uintptr_t)(i) >> 32) & 0xffff);     \
+			if (!((uintptr_t)(i) & 0xffff800000000000ULL))	      \
+				PPC_LI(d, ((uintptr_t)(i) >> 32) & 0xffff);   \
+			else {						      \
+				PPC_LIS(d, ((uintptr_t)(i) >> 48));	      \
+				if ((uintptr_t)(i) & 0x0000ffff00000000ULL)   \
+					PPC_ORI(d, d,			      \
+					  ((uintptr_t)(i) >> 32) & 0xffff);   \
+			}						      \
 			PPC_SLDI(d, d, 32);				      \
 			if ((uintptr_t)(i) & 0x00000000ffff0000ULL)	      \
 				PPC_ORIS(d, d,				      \
 					 ((uintptr_t)(i) >> 16) & 0xffff);    \
 			if ((uintptr_t)(i) & 0x000000000000ffffULL)	      \
 				PPC_ORI(d, d, (uintptr_t)(i) & 0xffff);	      \
-		} } while (0);
+		} } while (0)
 
 #ifdef CONFIG_PPC64
 #define PPC_FUNC_ADDR(d,i) do { PPC_LI64(d, i); } while(0)
-- 
2.7.4

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[RFC PATCH 0/6] eBPF JIT for PPC64 "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> - 2016-04-01 12:10 +0200
  [RFC PATCH 5/6] ppc: bpf/jit: Isolate classic BPF JIT specifics into a separate header "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> - 2016-04-01 12:10 +0200
  [RFC PATCH 6/6] ppc: ebpf/jit: Implement JIT compiler for extended BPF "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> - 2016-04-01 12:10 +0200
    Re: [RFC PATCH 6/6] ppc: ebpf/jit: Implement JIT compiler for  extended BPF Alexei Starovoitov <ast@fb.com> - 2016-04-01 20:20 +0200
      Re: [RFC PATCH 6/6] ppc: ebpf/jit: Implement JIT compiler for extended  BPF Daniel Borkmann <daniel@iogearbox.net> - 2016-04-01 20:40 +0200
  [RFC PATCH 3/6] ppc: bpf/jit: Introduce rotate immediate instructions "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> - 2016-04-01 12:10 +0200
  [RFC PATCH 4/6] ppc: bpf/jit: A few cleanups "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> - 2016-04-01 12:10 +0200
  [RFC PATCH 1/6] ppc: bpf/jit: Fix/enhance 32-bit Load Immediate implementation "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> - 2016-04-01 12:10 +0200
  [RFC PATCH 2/6] ppc: bpf/jit: Optimize 64-bit Immediate loads "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> - 2016-04-01 12:10 +0200
  Re: [RFC PATCH 0/6] eBPF JIT for PPC64 "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> - 2016-04-01 12:30 +0200

csiph-web