Take:
struct a
{
  union
  {
    int a;
    int b;
  };
  union
  {
    int c;
    int d;
  };
};

int f(struct a *c)
{
  int d = c->a;
  c->c = 1;
  return c->a + d;
}
--- CUT ---
There should only be one load from c->a but currently there is two


-- 
           Summary: Union in structs are not well optimized
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pinskia at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38207

Reply via email to