On Sat, Jan 13, 2024 at 8:46 AM 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`.
>
> 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?

There's no way to map back a structure field to all of its [implicit]
uses.  But the
set of variables to adjust should fall out trivially of the analysis phase that
determines whether the transform is valid (which is indeed the most complicated
part).

It might be possible to restrict the transform to certain objects
(rather than the "type").

There were several similar attempts on doing "struct reorg", the most recent by
people from amerecomputing IIRC.  I've always commented that trying to do
this on the types (and computing sth like "type escape") is wrong, analysis and
transform should be on individual instances of the type instead - those you can
actually analyze.

Richard.

>
> Thanks
> Hanke Zhang

Reply via email to