typedef struct { double min; double max; } interval; inline interval add(interval x, interval y) { interval r; r.min = x.min + y.min; r.max = x.max + y.max; return r; } interval foo (interval a, interval b, interval c) { return add (a, add (b, c)); }
for the temporary for gimplifying the nested call to add, the gimplifier introduces a temporary of type TYPE_MAIN_VARIANT (interval), which survives as added casts. This happens here: static inline tree create_tmp_from_val (tree val) { return create_tmp_var (TYPE_MAIN_VARIANT (TREE_TYPE (val)), get_name (val)); } in the optimized dump we still have foo (a, b, c) { double r$min; double r$min; double a$max; double a$min; struct interval y; struct { double min; double max; } D.1542; <bb 2>: a$max = a.max; a$min = a.min; r$min = b.min + c.min; D.1542.max = b.max + c.max; D.1542.min = r$min; y = (struct interval) D.1542; r$min = y.min + a$min; <retval>.max = y.max + a$max; <retval>.min = r$min; return <retval>; } by simply removing this TYPE_MAIN_VARAINT there we end up with two temporary structures less: Analyzing Edge Insertions. foo (a, b, c) { double r$min; <bb 2>: r$min = b.min + c.min + a.min; <retval>.max = b.max + c.max + a.max; <retval>.min = r$min; return <retval>; } -- Summary: gimplifier introduces unnecessary type conversions Product: gcc Version: 4.2.0 Status: UNCONFIRMED Keywords: missed-optimization, memory-hog, compile-time-hog 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=28075