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: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Subject: Re: powerpc: Discard ffs() function and use builtin_ffs instead
Date: Fri, 13 May 2016 16:16:57 +1000 (AEST) [thread overview]
Message-ID: <3r5flF6kL6z9t5R@ozlabs.org> (raw)
In-Reply-To: <20160512153222.6109E1A239A@localhost.localdomain>
On Thu, 2016-12-05 at 15:32:22 UTC, Christophe Leroy wrote:
> With the ffs() function as defined in arch/powerpc/include/asm/bitops.h
> GCC will not optimise the code in case of constant parameter, as shown
> by the small exemple below.
>
> int ffs_test(void)
> {
> return 4 << ffs(31);
> }
>
> c0012334 <ffs_test>:
> c0012334: 39 20 00 01 li r9,1
> c0012338: 38 60 00 04 li r3,4
> c001233c: 7d 29 00 34 cntlzw r9,r9
> c0012340: 21 29 00 20 subfic r9,r9,32
> c0012344: 7c 63 48 30 slw r3,r3,r9
> c0012348: 4e 80 00 20 blr
>
> With this patch, the same function will compile as follows:
>
> c0012334 <ffs_test>:
> c0012334: 38 60 00 08 li r3,8
> c0012338: 4e 80 00 20 blr
But what code does it generate when it's not a constant?
And which gcc version first added the builtin version?
cheers
next prev parent reply other threads:[~2016-05-13 6:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-12 15:32 [PATCH] " Christophe Leroy
2016-05-13 6:16 ` Michael Ellerman [this message]
2016-05-13 6:53 ` Christophe Leroy
2016-09-16 10:01 ` Christophe Leroy
2016-05-13 8:29 ` Gabriel Paubert
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=3r5flF6kL6z9t5R@ozlabs.org \
--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
all inboxes | Powered by JetHome®