IPA-SRA can do unused function parameter removal but misses unused return
value elimination. This can be useful for a function like
int
quantum_gate_counter(int inc)
{
static int counter = 0;
if(inc > 0)
counter += inc;
else if(inc < 0)
counter = 0;
return counter;
}
which is only used in places that do not use the returned value in which
case the function should be optimized away completely, eliminating
the counter updates. Note that this has to be done before inlining
into the callers to be effective.
The above missed-optimization blocks partial inlining of a function like
int flag;
int foo (void)
{
quantum_gate_counter (1);
if (!flag)
return 0;
...
}
--
Summary: Missed unused function return value elimination
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: enhancement
Priority: P3
Component: tree-optimization
AssignedTo: jamborm at gcc dot gnu dot org
ReportedBy: rguenth at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42970