From: "Måns Rullgård" <mans@mansr.com>
To: linux-kernel@vger.kernel.org
Subject: Re: [RFC][PATCH] introduce ptr_diff()
Date: Thu, 19 Aug 2010 17:18:42 +0100 [thread overview]
Message-ID: <yw1xaaoi8tjx.fsf@unicorn.mansr.com> (raw)
In-Reply-To: <5790.1282219392@redhat.com>
David Howells <dhowells@redhat.com> writes:
> Namhyung Kim <namhyung@gmail.com> wrote:
>
>> + if (is_power_of_2(__size)) \
>> + __diff = (__addr1 - __addr2) >> ilog2(__size); \
>> + else \
>> + __diff = (__addr1 - __addr2) / __size; \
>
> You shouldn't need to do this. The compiler's optimiser should switch a
> divide to a shift for a power-of-2 divisor.
Only when the numerator is provably non-negative, which is certainly
not the case here.
--
Måns Rullgård
mans@mansr.com
next prev parent reply other threads:[~2010-08-19 16:18 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-19 11:37 Namhyung Kim
2010-08-19 11:57 ` Bernd Petrovitsch
2010-08-19 12:03 ` David Howells
2010-08-19 16:18 ` Måns Rullgård [this message]
2010-08-19 12:23 ` Andi Kleen
2010-08-19 12:40 ` Matthew Wilcox
2010-08-19 12:58 ` Andi Kleen
2010-08-19 12:48 ` Bernd Petrovitsch
2010-08-19 12:59 ` Andi Kleen
2010-08-19 13:05 ` Bernd Petrovitsch
2010-08-19 13:39 ` Andi Kleen
2010-08-20 12:12 ` Al Viro
2010-08-19 15:53 ` Namhyung Kim
2010-08-19 16:04 ` Bernd Petrovitsch
2010-08-19 16:12 ` Namhyung Kim
2010-08-20 12:07 ` Al Viro
2010-08-20 12:49 ` Matthew Wilcox
2010-08-20 12:57 ` Andi Kleen
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=yw1xaaoi8tjx.fsf@unicorn.mansr.com \
--to=mans@mansr.com \
--cc=linux-kernel@vger.kernel.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®