From: Marc Glisse Date: Tue, 4 Jun 2019 20:39:32 +0000 (+0200) Subject: Simplify loop size when step=1 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4a28e1f11335c771e215d0cdbae630828c0acaf2;p=gcc.git Simplify loop size when step=1 2019-06-04 Marc Glisse * tree-ssa-loop-niter.c (number_of_iterations_ne): Skip computations when step is 1. From-SVN: r271926 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c7af3457858..30febc6fecc 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2019-06-04 Marc Glisse + + * tree-ssa-loop-niter.c (number_of_iterations_ne): Skip + computations when step is 1. + 2019-06-04 Segher Boessenkool * config/rs6000/constraints.md (define_register_constraint "wf"): diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c index 470b6a295be..8cf8ef92b01 100644 --- a/gcc/tree-ssa-loop-niter.c +++ b/gcc/tree-ssa-loop-niter.c @@ -1125,8 +1125,15 @@ number_of_iterations_ne (struct loop *loop, tree type, affine_iv *iv, } c = fold_build2 (EXACT_DIV_EXPR, niter_type, c, d); - tmp = fold_build2 (MULT_EXPR, niter_type, c, inverse (s, bound)); - niter->niter = fold_build2 (BIT_AND_EXPR, niter_type, tmp, bound); + if (integer_onep (s)) + { + niter->niter = c; + } + else + { + tmp = fold_build2 (MULT_EXPR, niter_type, c, inverse (s, bound)); + niter->niter = fold_build2 (BIT_AND_EXPR, niter_type, tmp, bound); + } return true; }