public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Michael Ellerman <mpe@ellerman.id.au>
To: Christophe Leroy <christophe.leroy@c-s.fr>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Paul Mackerras <paulus@samba.org>, Scott Wood <oss@buserror.net>
Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH] powerpc: sysdev: cpm1: Optimise gpio bit calculation
Date: Fri, 10 Mar 2017 19:41:33 +1100	[thread overview]
Message-ID: <87a88tle0y.fsf@concordia.ellerman.id.au> (raw)
In-Reply-To: <20170309094206.A832167992@localhost.localdomain>

Christophe Leroy <christophe.leroy@c-s.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

  reply	other threads:[~2017-03-10  8:41 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-09  9:42 [PATCH] powerpc: sysdev: cpm1: Optimise gpio bit calculation Christophe Leroy
2017-03-10  8:41 ` Michael Ellerman [this message]
2017-03-10 10:54   ` Christophe LEROY
2017-03-10 13:06     ` Segher Boessenkool
2017-03-10 14:04       ` Christophe LEROY
2017-03-10 14:32         ` Segher Boessenkool
2017-03-10 14:41           ` Christophe LEROY
2017-03-10 15:41             ` Segher Boessenkool
2017-03-21 15:04               ` Christophe LEROY
2017-03-10 13:02   ` Segher Boessenkool

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87a88tle0y.fsf@concordia.ellerman.id.au \
    --to=mpe@ellerman.id.au \
    --cc=benh@kernel.crashing.org \
    --cc=christophe.leroy@c-s.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=oss@buserror.net \
    --cc=paulus@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox