From: Heiko Carstens <hca@linux.ibm.com>
To: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Cc: Nathan Chancellor <nathan@kernel.org>,
Miguel Ojeda <ojeda@kernel.org>,
Vasily Gorbik <gor@linux.ibm.com>,
Alexander Gordeev <agordeev@linux.ibm.com>,
Juergen Christ <jchrist@linux.ibm.com>,
linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org,
Sven Schnelle <svens@linux.ibm.com>,
Christian Borntraeger <borntraeger@linux.ibm.com>
Subject: Re: [PATCH 1/3] Compiler Attributes: Add __assume macro
Date: Fri, 12 Sep 2025 12:25:54 +0200 [thread overview]
Message-ID: <20250912102554.10147Bf8-hca@linux.ibm.com> (raw)
In-Reply-To: <CANiq72=Zhcrk-cvXX+75mQzqUUwQznkZmLTCoEn0XNs62meUtQ@mail.gmail.com>
On Thu, Sep 11, 2025 at 08:59:29PM +0200, Miguel Ojeda wrote:
> On Wed, Sep 10, 2025 at 5:12 PM Heiko Carstens <hca@linux.ibm.com> wrote:
> >
> > + * Beware: Code which makes use of __assume must be written as if the compiler
> > + * ignores the hint. Otherwise this may lead to subtle bugs if code is compiled
> > + * with compilers which do not support the attribute.
>
> I am not sure I understand this "Beware:" comment: is it referring to
> evaluation side-effects? If so, the GCC docs say it is not evaluated.
> The real danger is triggering UB with it, but that is different, i.e.
> one needs to be really, really sure the expression is true.
No, I was referring to the original build error where the missing "& 127" lead
to a warning / build error. So what I was trying to say: if you have a
construct like:
...
return a & 127;
and then make this:
...
__assume(a < 64);
return a & 127;
then it is not possible to leave the "& 127" part away, since __assume() is
optional. But thinking about this again, I guess the comment is misleading,
like also your reply proved.
This is not about subtle bugs, but just an optimization that is not being
done, which may or may not lead to compile time warnings for the particular
case I was trying to improve; but the code would be correct in any case, as
long as __assume() is used correctly.
I'll rephrase the comment, and split / reorder patches differently so it is
(hopefully) more obvious what I try to achieve: allow for micro-optimizations
of inline assembly outputs.
next prev parent reply other threads:[~2025-09-12 10:26 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-10 15:12 [PATCH 0/3] s390: Fix and optimize __flogr() inline assembly Heiko Carstens
2025-09-10 15:12 ` [PATCH 1/3] Compiler Attributes: Add __assume macro Heiko Carstens
2025-09-11 1:32 ` Nathan Chancellor
2025-09-11 14:56 ` Heiko Carstens
2025-09-11 18:44 ` Nathan Chancellor
2025-09-11 19:04 ` Miguel Ojeda
2025-09-11 20:42 ` Nathan Chancellor
2025-09-11 18:56 ` Miguel Ojeda
2025-09-11 18:59 ` Miguel Ojeda
2025-09-12 10:25 ` Heiko Carstens [this message]
2025-09-10 15:12 ` [PATCH 2/3] s390/bitops: Limit return value range of __flogr() Heiko Carstens
2025-09-11 7:44 ` Juergen Christ
2025-09-11 13:24 ` kernel test robot
2025-09-10 15:12 ` [PATCH 3/3] s390/bitops: Remove volatile qualifier from flogr() inline assembly Heiko Carstens
2025-09-11 7:45 ` Juergen Christ
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=20250912102554.10147Bf8-hca@linux.ibm.com \
--to=hca@linux.ibm.com \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=jchrist@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=miguel.ojeda.sandonis@gmail.com \
--cc=nathan@kernel.org \
--cc=ojeda@kernel.org \
--cc=svens@linux.ibm.com \
/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