[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87a88tle0y.fsf@concordia.ellerman.id.au>
Date: Fri, 10 Mar 2017 19:41:33 +1100
From: Michael Ellerman <mpe@...erman.id.au>
To: Christophe Leroy <christophe.leroy@....fr>,
Benjamin Herrenschmidt <benh@...nel.crashing.org>,
Paul Mackerras <paulus@...ba.org>,
Scott Wood <oss@...error.net>
Cc: linux-kernel@...r.kernel.org, linuxppc-dev@...ts.ozlabs.org
Subject: Re: [PATCH] powerpc: sysdev: cpm1: Optimise gpio bit calculation
Christophe Leroy <christophe.leroy@....fr> 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 0x80000000 >> i;
> }
>
> Disassembly of section .text:
>
> 00000000 <f>:
> 0: 20 63 00 1f subfic r3,r3,31
> 4: 39 20 00 01 li r9,1
> 8: 7d 23 18 30 slw r3,r9,r3
> c: 4e 80 00 20 blr
>
> 00000010 <g>:
> 10: 3d 20 80 00 lis r9,-32768
> 14: 7d 23 1c 30 srw r3,r9,r3
> 18: 4e 80 00 20 blr
Well yeah, it saves one instruction, but is it worth it? Are these gpio
routines in some hot path I don't know about?
cheers
Powered by blists - more mailing lists