union X { int i; double x; }; int foo (union X *p) { union X x = *p; return x.x; }
produces union X x.0; x.0 = *p; x = x.0; this is not optimized at any point. Using a struct instead usually SRA is able to remove the extra copy. -- Summary: gimplification of aggregate copies introduces extra aggregate copy Product: gcc Version: 4.4.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: middle-end AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: rguenth at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36326