https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121493
Bug ID: 121493
Summary: Another missing Fre from a copy
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Target Milestone: ---
Testcase:
```
struct s1
{
int t;
};
struct s2
{
struct s1 t;
};
int f1(int a)
{
s1 t{a};
s2 tt{t};
s2 ttt = tt;
s1 *t0 = &ttt.t;
return t0->t;
}
int f2(int a)
{
s1 t{a};
s2 tt{t};
s2 ttt = tt;
return ttt.t.t;
}
```
Compile with `-O2 -fno-tree-sra` and see that f1 is not able to optimize to
just `return a`. While f2 is.
The only difference between the two at fre1 is:
_7 = MEM[(struct s1 *)&ttt].t;
vs:
_6 = ttt.t.t;
Noticed this while looking into PR 92811 if we disable SRA.