https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117971

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
One simple issue is we don't optimize something like this:
```
struct a
{
  int tt;
  int t[1023];
};

void g(struct a *b)
{
  struct a c = {};
  c.tt = 2;
  *b = c;
}
```

After I finish up my current set of copy propagation for aggregates patches I
might come back to this one. We should be able to remove the tempory here too.

In the original testcase we have:
```
  MEM <char[40]> [(struct variant *)&D.10906] = {};
  D.10906._storage._which = 2;
  t = D.10906;
  MEM[(struct variant_ref *)&D.10783] ={v} {CLOBBER(bob)};
  MEM[(struct variant_ref *)&D.10783].inner_storage_ = t;
```

With my set of patches we get:
```
  MEM <char[40]> [(struct variant *)&D.9289] = {};
  MEM[(struct variant_ref *)&D.9158] ={v} {CLOBBER(bob)};
  D.9289._storage._which = 2;
  MEM[(struct variant_ref *)&D.9158].inner_storage_ = D.9289;
  D.9289 ={v} {CLOBBER(eos)};
```

Removing one temporary but still have an extra one.

Reply via email to