public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Siddhesh Poyarekar <siddhesh@gotplt.org>,
	Richard Biener <richard.guenther@gmail.com>,
	gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] tree-optimization/108522 Use COMPONENT_REF offset when available
Date: Wed, 25 Jan 2023 12:33:47 +0100	[thread overview]
Message-ID: <Y9ETmx2jqwhdjV/K@tucnak> (raw)
In-Reply-To: <Y9ESEXb6voOwJ2B7@tucnak>

On Wed, Jan 25, 2023 at 12:27:13PM +0100, Jakub Jelinek via Gcc-patches wrote:
> On Wed, Jan 25, 2023 at 06:22:56AM -0500, Siddhesh Poyarekar wrote:
> > On 2023-01-25 02:44, Richard Biener wrote:
> > > >         t = TREE_OPERAND (expr, 1);
> > > > -      off = size_binop (PLUS_EXPR, DECL_FIELD_OFFSET (t),
> > > > +      off = size_binop (PLUS_EXPR,
> > > > +                       (TREE_OPERAND (expr, 2) ? TREE_OPERAND (expr, 2)
> > > > +                        : DECL_FIELD_OFFSET (t)),
> > > 
> > > That isn't correct - operand 2 is the field offset in units of
> > > DECL_OFFSET_ALIGN (t) / BITS_PER_UNIT.
> > > See component_ref_filed_offset (), maybe you should be using that
> > > function instead?
> > 
> > Ahh, and it passed my testing only because I was testing a char. Thanks,
> > I'll test and send an update with additional tests.
> 
> I think you want something like:
>   struct S {
>     char a[n];
>     unsigned long long b;
>     int d;
>     char e[2 * n];
>   } s;
> and test say bdos of &s.d, 0 and &s.e[n - 2], 0

And in the caller compared that to offsetof/sizeof based expressions
for a similar structure which just uses constants instead of the n
in there.

	Jakub


      reply	other threads:[~2023-01-25 11:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-24 21:54 Siddhesh Poyarekar
2023-01-24 22:09 ` Jakub Jelinek
2023-01-25  7:44 ` Richard Biener
2023-01-25  8:24   ` Jakub Jelinek
2023-01-25 11:22   ` Siddhesh Poyarekar
2023-01-25 11:27     ` Jakub Jelinek
2023-01-25 11:33       ` Jakub Jelinek [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=Y9ETmx2jqwhdjV/K@tucnak \
    --to=jakub@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=richard.guenther@gmail.com \
    --cc=siddhesh@gotplt.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 read-only IMAP folder(s) and NNTP newsgroup(s).