From: Matthew Wilcox <willy@infradead.org>
To: David Howells <dhowells@redhat.com>
Cc: linux-fsdevel@vger.kernel.org,
Christian Brauner <brauner@kernel.org>,
Paulo Alcantara <pc@manguebit.org>,
netfs@lists.linux.dev
Subject: Re: [PATCH 08/10] netfs: Use folio_next_pos()
Date: Mon, 27 Oct 2025 14:50:59 +0000 [thread overview]
Message-ID: <aP-G085ZIN_lR9c0@casper.infradead.org> (raw)
In-Reply-To: <2253016.1761574605@warthog.procyon.org.uk>
On Mon, Oct 27, 2025 at 02:16:45PM +0000, David Howells wrote:
> Matthew Wilcox (Oracle) <willy@infradead.org> wrote:
>
> > This is one instruction more efficient than open-coding folio_pos() +
> > folio_size(). It's the equivalent of (x + y) << z rather than
> > x << z + y << z.
>
> Should that be noted to the gcc bugzilla as a missed optimisation?
I don't know? Maybe there's a Law Of C Arithmetic that prevents it
from doing this optimisation that we can ignore because we know that
the calculation will never overflow.
I tried with both gcc and LLVM and both produce better code for g()
than for f():
https://godbolt.org/z/YTc883f6G
Interestingly, LLVM does better for f() than gcc does, but they produce
identical code for g() (minor difference like using sal instead of shl
but that feels unimportant).
If you want to file optimisation bug(s) against gcc, feel free to use
this example code.
prev parent reply other threads:[~2025-10-27 14:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20251024170822.1427218-1-willy@infradead.org>
2025-10-24 17:08 ` [PATCH 08/10] netfs: Use folio_next_pos() Matthew Wilcox (Oracle)
2025-10-24 17:36 ` Paulo Alcantara
2025-10-27 14:16 ` David Howells
2025-10-27 14:50 ` Matthew Wilcox [this message]
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=aP-G085ZIN_lR9c0@casper.infradead.org \
--to=willy@infradead.org \
--cc=brauner@kernel.org \
--cc=dhowells@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=netfs@lists.linux.dev \
--cc=pc@manguebit.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;
as well as URLs for NNTP newsgroup(s).