diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 13c7a178992..c6e2ad55422 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2005-07-27 Zdenek Dvorak + + PR tree-optimize/22348 + * tree-ssa-loop-niter.c (number_of_iterations_cond): + Fold the partial computation. + 2005-07-27 Zdenek Dvorak PR tree-optimization/22325 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 60889ca7a6f..0e3760d3e1a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2005-07-27 Zdenek Dvorak + + PR tree-optimize/22348 + * gcc.c-torture/execute/pr22348.c: New. + 2005-07-27 Richard Guenther * gcc.dg/tree-ssa/salias-1.c: New testcase. diff --git a/gcc/testsuite/gcc.c-torture/execute/pr22348.c b/gcc/testsuite/gcc.c-torture/execute/pr22348.c new file mode 100644 index 00000000000..9192d5130c6 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr22348.c @@ -0,0 +1,15 @@ +void abort (void); +void f(int i) +{ + if (i>4 + 3 * 16) + abort(); +} + +int main() +{ + unsigned int buflen, i; + buflen = 4 + 3 * 16; + for (i = 4; i < buflen; i+= 3) + f(i); + return 0; +} diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c index 891dc0c13d1..37cd4003d47 100644 --- a/gcc/tree-ssa-loop-niter.c +++ b/gcc/tree-ssa-loop-niter.c @@ -275,7 +275,7 @@ number_of_iterations_cond (tree type, tree base0, tree step0, step = fold_unary_to_constant (NEGATE_EXPR, type, step1); else step = step0; - delta = build2 (MINUS_EXPR, type, base1, base0); + delta = fold_build2 (MINUS_EXPR, type, base1, base0); delta = fold_build2 (FLOOR_MOD_EXPR, type, delta, step); may_xform = boolean_false_node;