http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59786
Bug ID: 59786
Summary: GIMPLE invariant motion misses opportunity to reduce
register pressure
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: rguenth at gcc dot gnu.org
For the following testcase LIM doesn't hoist a + b out of the loop (use -O1)
int x[1024];
void foo (int a, int b)
{
int i;
for (i = 0; i < 1024; ++i)
x[i] = a + b;
}
_6 = a_4(D) + b_5(D);
invariant up to level 1, cost 1.
but
/* The cost of expression in loop invariant motion that is considered
expensive. */
DEFPARAM(PARAM_LIM_EXPENSIVE,
"lim-expensive",
"The minimum cost of an expensive expression in the loop invariant
motion",
20, 0, 0)
and we only hoist "expensive" computations. What is considered expensive
should consider the effect on register pressure.
Note that PRE happily moves all invariants without cost consideration.
For the testcase later RTL invariant motion hoists the addition.