Re: [PATCH] powerpc: sysdev: cpm1: Optimise gpio bit calculation

2017-03-21 Thread Christophe LEROY
Le 10/03/2017 à 16:41, Segher Boessenkool a écrit : On Fri, Mar 10, 2017 at 03:41:23PM +0100, Christophe LEROY wrote: gpio_get() and gpio_set() are used extensively by some GPIO based drivers like SPI, NAND, so it may be worth it as it doesn't impair readability (if anyone prefers, we could

Re: [PATCH] powerpc: sysdev: cpm1: Optimise gpio bit calculation

2017-03-10 Thread Segher Boessenkool
On Fri, Mar 10, 2017 at 03:41:23PM +0100, Christophe LEROY wrote: > gpio_get() and gpio_set() are used extensively by some GPIO based > drivers like SPI, NAND, so it may be worth it as it doesn't impair > readability (if anyone prefers, we could write (1 << 31) >> i instead > of

Re: [PATCH] powerpc: sysdev: cpm1: Optimise gpio bit calculation

2017-03-10 Thread Christophe LEROY
Le 10/03/2017 à 15:32, Segher Boessenkool a écrit : On Fri, Mar 10, 2017 at 03:04:48PM +0100, Christophe LEROY wrote: Le 10/03/2017 à 14:06, Segher Boessenkool a écrit : On Fri, Mar 10, 2017 at 11:54:19AM +0100, Christophe LEROY wrote: gpio_get() and gpio_set() are used extensively by some

Re: [PATCH] powerpc: sysdev: cpm1: Optimise gpio bit calculation

2017-03-10 Thread Segher Boessenkool
On Fri, Mar 10, 2017 at 03:04:48PM +0100, Christophe LEROY wrote: > Le 10/03/2017 à 14:06, Segher Boessenkool a écrit : > >On Fri, Mar 10, 2017 at 11:54:19AM +0100, Christophe LEROY wrote: > >>gpio_get() and gpio_set() are used extensively by some GPIO based > >>drivers like SPI, NAND, so it may

Re: [PATCH] powerpc: sysdev: cpm1: Optimise gpio bit calculation

2017-03-10 Thread Christophe LEROY
Le 10/03/2017 à 14:06, Segher Boessenkool a écrit : On Fri, Mar 10, 2017 at 11:54:19AM +0100, Christophe LEROY wrote: gpio_get() and gpio_set() are used extensively by some GPIO based drivers like SPI, NAND, so it may be worth it as it doesn't impair readability (if anyone prefers, we could

Re: [PATCH] powerpc: sysdev: cpm1: Optimise gpio bit calculation

2017-03-10 Thread Segher Boessenkool
On Fri, Mar 10, 2017 at 11:54:19AM +0100, Christophe LEROY wrote: > gpio_get() and gpio_set() are used extensively by some GPIO based > drivers like SPI, NAND, so it may be worth it as it doesn't impair > readability (if anyone prefers, we could write (1 << 31) >> i instead > of 0x8000

Re: [PATCH] powerpc: sysdev: cpm1: Optimise gpio bit calculation

2017-03-10 Thread Segher Boessenkool
On Fri, Mar 10, 2017 at 07:41:33PM +1100, Michael Ellerman wrote: > Well yeah, it saves one instruction, but is it worth it? Are these gpio > routines in some hot path I don't know about? If there was a GCC PR for this we probably would make GCC optimise this; there are many similar things that

Re: [PATCH] powerpc: sysdev: cpm1: Optimise gpio bit calculation

2017-03-10 Thread Christophe LEROY
Le 10/03/2017 à 09:41, Michael Ellerman a écrit : Christophe Leroy writes: Help a bit the compiler to provide better code: unsigned int f(int i) { return 1 << (31 - i); } unsigned int g(int i) { return 0x8000 >> i; } Disassembly of section

Re: [PATCH] powerpc: sysdev: cpm1: Optimise gpio bit calculation

2017-03-10 Thread Michael Ellerman
Christophe Leroy writes: > Help a bit the compiler to provide better code: > > unsigned int f(int i) > { > return 1 << (31 - i); > } > > unsigned int g(int i) > { > return 0x8000 >> i; > } > > Disassembly of section .text: > > : >0: 20 63 00

[PATCH] powerpc: sysdev: cpm1: Optimise gpio bit calculation

2017-03-09 Thread Christophe Leroy
Help a bit the compiler to provide better code: unsigned int f(int i) { return 1 << (31 - i); } unsigned int g(int i) { return 0x8000 >> i; } Disassembly of section .text: : 0: 20 63 00 1f subfic r3,r3,31 4: 39 20 00 01 li r9,1 8: 7d 23