http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46186
--- Comment #23 from sebpop at gmail dot com <sebpop at gmail dot com>
2010-10-29 21:44:09 UTC ---
Hi,
here is a preliminary patch (not tested yet other that the PR testcase).
This patch improves chrec_apply to also handle these very uncommon
cases that some like to make big titles about (I wonder if the guy who
submitted this bug report is part of some marketing division... anyways)
Note that for these cases
F (4, sum += a * a)
F (5, sum += a * a * a)
F (6, sum += a * a * a * a * a + 2 * a * a * a + 5 * a)
although GCC with this patch knows how to transform these into end
of loop values, GCC won't change them, because of this heuristic:
/* Do not emit expensive expressions. The rationale is that
when someone writes a code like
while (n > 45) n -= 45;
he probably knows that n is not large, and does not want it
to be turned into n %= 45. */
|| expression_expensive_p (def))
one needs to also set the --param scev-max-expr-size to a pretty big
value for f6 to pass the fold steps...
Sebastian