From: Joseph Myers <joseph@codesourcery.com>
To: Ties Klappe <tg.klappe@gmail.com>
Cc: <gcc@gcc.gnu.org>
Subject: Re: Unjustified optimization due to restricted struct members?
Date: Thu, 30 Nov 2023 17:16:53 +0000 [thread overview]
Message-ID: <ee19dc84-c842-e88-69fa-bbcb249f14ab@codesourcery.com> (raw)
In-Reply-To: <CAHSOcvA-Ko8a3f8G_4fHxcKh+Nd-T6JiXRzeBQhxHq1Tsx+MdA@mail.gmail.com>
On Thu, 30 Nov 2023, Ties Klappe via Gcc wrote:
> When reading section 6.7.3.1 of the C standard (quoted below) about
> the *restrict
> *type qualifier, the first section talks about *ordinary identifiers*.
> These are defined in section 6.2.3, and exclude members of structures.
>
> Let D be a declaration of an ordinary identifier that provides a means of
> > designating an object P as a restrict-qualified pointer to type T.
>
>
> I would assume that this means that in the code excerpt below the function
> *h* cannot be optimized by substituting the load of *b.p *for *10*, as the
> standard does not specify what it means for a struct member to be restrict
> qualified. However, the code is still optimized by gcc (but not Clang), as
> can be seen here: https://godbolt.org/z/hEnKKoaae
>
> struct bar {
> int* restrict p;
> int* restrict q;
> };
>
> int h(struct bar b) {
In this code, 'b' is the ordinary identifier; "struct bar b" is the
declaration D. The declaration does not itself need to have pointer type.
--
Joseph S. Myers
joseph@codesourcery.com
prev parent reply other threads:[~2023-11-30 17:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-30 11:05 Ties Klappe
2023-11-30 12:12 ` Richard Biener
2023-11-30 12:50 ` Ties Klappe
2023-11-30 13:06 ` Richard Biener
2023-11-30 17:16 ` Joseph Myers [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=ee19dc84-c842-e88-69fa-bbcb249f14ab@codesourcery.com \
--to=joseph@codesourcery.com \
--cc=gcc@gcc.gnu.org \
--cc=tg.klappe@gmail.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).