linux/arch
Christophe Leroy 22ef33b368 powerpc: Replace ffz() by equivalent generic function
With the ffz() function as defined in arch/powerpc/include/asm/bitops.h
GCC will not optimise the code in case of constant parameter.

This patch replaces ffz() by the generic function.

The generic ffz(x) expects to never be called with ~x == 0
as written in the comment in include/asm-generic/bitops/ffz.h
The only user of ffz() within arch/powerpc/ is
platforms/512x/mpc5121_ads_cpld.c, which checks if x is not 0xff

For non constant calls, the generated code is doing the same:

unsigned long testffz(unsigned long x)
{
	return ffz(x);
}

On PPC32, before the patch:
00000018 <testffz>:
  18:	7c 63 18 f9 	not.    r3,r3
  1c:	40 82 00 0c 	bne     28 <testffz+0x10>
  20:	38 60 00 20 	li      r3,32
  24:	4e 80 00 20 	blr
  28:	7d 23 00 d0 	neg     r9,r3
  2c:	7d 23 18 38 	and     r3,r9,r3
  30:	7c 63 00 34 	cntlzw  r3,r3
  34:	20 63 00 1f 	subfic  r3,r3,31
  38:	4e 80 00 20 	blr

On PPC32, after the patch:
00000018 <testffz>:
  18:	39 23 00 01 	addi    r9,r3,1
  1c:	7d 23 18 78 	andc    r3,r9,r3
  20:	7c 63 00 34 	cntlzw  r3,r3
  24:	20 63 00 1f 	subfic  r3,r3,31
  28:	4e 80 00 20 	blr

On PPC64, before the patch:
0000000000000030 <.testffz>:
  30:	7c 60 18 f9 	not.    r0,r3
  34:	38 60 00 40 	li      r3,64
  38:	4d 82 00 20 	beqlr
  3c:	7c 60 00 d0 	neg     r3,r0
  40:	7c 63 00 38 	and     r3,r3,r0
  44:	7c 63 00 74 	cntlzd  r3,r3
  48:	20 63 00 3f 	subfic  r3,r3,63
  4c:	7c 63 07 b4 	extsw   r3,r3
  50:	4e 80 00 20 	blr

On PPC64, after the patch:
0000000000000030 <.testffz>:
  30:	38 03 00 01 	addi    r0,r3,1
  34:	7c 03 18 78 	andc    r3,r0,r3
  38:	7c 63 00 74 	cntlzd  r3,r3
  3c:	20 63 00 3f 	subfic  r3,r3,63
  40:	4e 80 00 20 	blr

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2017-06-02 19:23:55 +10:00
..
alpha osf_wait4(): fix infoleak 2017-05-21 13:10:07 -04:00
arc Kbuild UAPI header export updates for v4.12 2017-05-10 20:45:36 -07:00
arm KVM fixes for v4.12-rc2 2017-05-19 15:13:13 -07:00
arm64 arm64: dts: hikey: Fix WiFi support 2017-05-23 14:18:10 +02:00
blackfin uapi: export all headers under uapi directories 2017-05-11 00:21:54 +09:00
c6x uapi: export all headers under uapi directories 2017-05-11 00:21:54 +09:00
cris devicetree: Move include prefixes from arch to separate directory 2017-05-18 23:55:48 -07:00
frv Kbuild UAPI header export updates for v4.12 2017-05-10 20:45:36 -07:00
h8300 uapi: export all headers under uapi directories 2017-05-11 00:21:54 +09:00
hexagon uapi: export all headers under uapi directories 2017-05-11 00:21:54 +09:00
ia64 Kbuild UAPI header export updates for v4.12 2017-05-10 20:45:36 -07:00
m32r uapi: export all headers under uapi directories 2017-05-11 00:21:54 +09:00
m68k uapi: export all headers under uapi directories 2017-05-11 00:21:54 +09:00
metag devicetree: Move include prefixes from arch to separate directory 2017-05-18 23:55:48 -07:00
microblaze uapi: export all headers under uapi directories 2017-05-11 00:21:54 +09:00
mips devicetree: Move include prefixes from arch to separate directory 2017-05-18 23:55:48 -07:00
mn10300 uapi: export all headers under uapi directories 2017-05-11 00:21:54 +09:00
nios2 nios2 update for v4.12-rc1 2017-05-12 09:53:16 -07:00
openrisc uapi: export all headers under uapi directories 2017-05-11 00:21:54 +09:00
parisc uapi: export all headers under uapi directories 2017-05-11 00:21:54 +09:00
powerpc powerpc: Replace ffz() by equivalent generic function 2017-06-02 19:23:55 +10:00
s390 Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux 2017-05-16 09:24:44 -07:00
score uapi: export all headers under uapi directories 2017-05-11 00:21:54 +09:00
sh Kbuild UAPI header export updates for v4.12 2017-05-10 20:45:36 -07:00
sparc sparc/ftrace: Fix ftrace graph time measurement 2017-05-17 12:07:47 -07:00
tile arch/include: remove empty Kbuild files 2017-05-11 00:22:18 +09:00
um Merge branch 'for-linus-4.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rw/uml 2017-05-13 10:20:02 -07:00
unicore32 Kbuild UAPI header export updates for v4.12 2017-05-10 20:45:36 -07:00
x86 Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2017-05-27 09:17:58 -07:00
xtensa uapi: export all headers under uapi directories 2017-05-11 00:21:54 +09:00
.gitignore
Kconfig Merge branch 'core-rcu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2017-05-10 10:30:46 -07:00