public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Hanke Zhang <hkzhang455@gmail.com>
To: Iain Sandoe <idsandoe@googlemail.com>
Cc: GCC Development <gcc@gcc.gnu.org>
Subject: Re: How to compress the size of a field in a structure?
Date: Sun, 14 Jan 2024 15:43:06 +0800	[thread overview]
Message-ID: <CAM_DAs-M9AZ+KX_YVqHF9J814YF3wSte6GMm998K0VraV3Wc4Q@mail.gmail.com> (raw)
In-Reply-To: <4DA8BFC2-CF28-4131-8123-5914BF432EE8@googlemail.com>

Hi lain,

Thanks for your thoughtful comments and concerns. The primary goal of
compressing the structure fields is to achieve memory efficiency. I
understand your points regarding potential issues with modifying the
size and types of the structure. I guess rewriting all the
corresponding statements may help with it. If there are some more
complex situations, we will give up this optimization.

But I'm more concerned about how to accomplish this.

Thanks
Hanke Zhang

Iain Sandoe <idsandoe@googlemail.com> 于2024年1月13日周六 17:15写道:
>
>
>
> > On 13 Jan 2024, at 07:45, Hanke Zhang via Gcc <gcc@gcc.gnu.org> wrote:
> >
> > Hi, I'm attempting to compress the size of a field in a structure for
> > memory-friendly purposes. I created an IPA pass to achieve this, but I
> > ran into some issues as follows:
> >
> > // original
> > struct Foo {
> >  long a1;
> >  int a2;
> > };
> >
> > // modified
> > struct Foo_update {
> >  int a1;
> >  int a2;
> > };
> >
> > For the example structure Foo, I use `TREE_TYPE (field) =
> > integer_type_node` to compress the type of a1 from `long` to `int`.
>
> Hmm.  I am curious about under what conditions this is expected to work.
>
> Altering the size of the structure (or the types it contains) would break guarantees
> expected by at least c-family languages   - like sizeof, alignof
> what about arrays of the type, or embedding the type in larger aggregates?
>
> Iain
>
> > But I don't know how to update its corresponding SSA variables,
> > because the number of them is huge. Is there any way to do it quickly?
> >
> > Thanks
> > Hanke Zhang
>

  reply	other threads:[~2024-01-14  7:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-13  7:45 Hanke Zhang
2024-01-13  9:15 ` Iain Sandoe
2024-01-14  7:43   ` Hanke Zhang [this message]
2024-01-15  9:16 ` Richard Biener

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=CAM_DAs-M9AZ+KX_YVqHF9J814YF3wSte6GMm998K0VraV3Wc4Q@mail.gmail.com \
    --to=hkzhang455@gmail.com \
    --cc=gcc@gcc.gnu.org \
    --cc=idsandoe@googlemail.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).