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>
Cc: 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:27:13 +0100	[thread overview]
Message-ID: <Y9ESEXb6voOwJ2B7@tucnak> (raw)
In-Reply-To: <a1e4d431-927c-8a41-1d76-bf89531ee7fe@gotplt.org>

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

	Jakub


  reply	other threads:[~2023-01-25 11:27 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 [this message]
2023-01-25 11:33       ` Jakub Jelinek

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=Y9ESEXb6voOwJ2B7@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).