From: Richard Henderson <richard.henderson@linaro.org>
To: Pierrick Bouvier <pierrick.bouvier@linaro.org>,
Peter Maydell <peter.maydell@linaro.org>,
qemu-arm@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [PATCH] target/arm: Provide always-false kvm_arm_*_supported() stubs for usermode
Date: Mon, 14 Jul 2025 09:52:28 -0600 [thread overview]
Message-ID: <6f0cd2fd-2152-4c28-8dd1-ca7271e686f4@linaro.org> (raw)
In-Reply-To: <95b00393-bdd2-4db3-ac39-02a09f83b4d7@linaro.org>
On 7/14/25 09:41, Pierrick Bouvier wrote:
> Indeed, clang does not fold the condition "value && kvm_enabled() && !
> kvm_arm_sve_supported()". Looks like a missing case.
> This code compiles with gcc -O0, but not clang -O0.
>
> extern int f(void);
> int main(int argc) {
> if (argc && 0)
> f();
> }
>
> As folding is not guaranteed by C standard, I'm not sure it's really possible to file a
> bug. However, since we rely on this behaviour in other parts, maybe it would be better to
> rewrite the condition on our side.
It's probably worth filing a missed-optimization type bug, if that's available in clang's
reporting system.
With my compiler hat on, I suspect that GCC generates IR like
if (argc) {
if (0) {
f();
}
}
in order to get the short-circuting part of && correct, which Just So Happens to fold away
exactly as we wish.
I'm not sure how clang expands the expression such that (x && 0) doesn't fold away, but (0
&& x) does, as evidenced by
> + if (kvm_enabled() && !kvm_arm_sve_supported()) {
r~
next prev parent reply other threads:[~2025-07-14 16:55 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-14 13:51 [PATCH] target/arm: Provide always-false kvm_arm_*_supported() stubs for usermode Peter Maydell
2025-07-14 15:31 ` Pierrick Bouvier
2025-07-14 15:41 ` Pierrick Bouvier
2025-07-14 15:52 ` Richard Henderson [this message]
2025-07-14 17:38 ` Pierrick Bouvier
2025-07-15 20:43 ` Pierrick Bouvier
2025-07-14 19:49 ` Philippe Mathieu-Daudé
2025-07-17 16:56 ` Peter Maydell
2025-07-17 17:05 ` Pierrick Bouvier
2025-07-17 17:12 ` Peter Maydell
2025-07-17 17:29 ` Pierrick Bouvier
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=6f0cd2fd-2152-4c28-8dd1-ca7271e686f4@linaro.org \
--to=richard.henderson@linaro.org \
--cc=peter.maydell@linaro.org \
--cc=pierrick.bouvier@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.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).