From b8b31957e4c7e28fc44ae1b1ce658ba49ff1aa18 Mon Sep 17 00:00:00 2001 From: Kugan Vivekanandarajah Date: Fri, 6 Jul 2018 22:12:52 +0000 Subject: [PATCH] tree-ssa-loop-niter.c (number_of_iterations_popcount): If popcount argument is checked for zero before entering loop, avoid checking again. gcc/ChangeLog: 2018-07-06 Kugan Vivekanandarajah * tree-ssa-loop-niter.c (number_of_iterations_popcount): If popcount argument is checked for zero before entering loop, avoid checking again. From-SVN: r262487 --- gcc/ChangeLog | 5 +++++ gcc/tree-ssa-loop-niter.c | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index acaea119eaf..10137d6b411 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2018-07-06 Kugan Vivekanandarajah + + * tree-ssa-loop-niter.c (number_of_iterations_popcount): If popcount + argument is checked for zero before entering loop, avoid checking again. + 2018-07-06 Kugan Vivekanandarajah * gimplify.h (generic_expr_could_trap_p): Set as global function. diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c index 03588a012bd..f6fa2f74744 100644 --- a/gcc/tree-ssa-loop-niter.c +++ b/gcc/tree-ssa-loop-niter.c @@ -2596,10 +2596,15 @@ number_of_iterations_popcount (loop_p loop, edge exit, niter->niter = iter; niter->assumptions = boolean_true_node; + if (adjust) - niter->may_be_zero = fold_build2 (EQ_EXPR, boolean_type_node, src, + { + tree may_be_zero = fold_build2 (EQ_EXPR, boolean_type_node, src, build_zero_cst (TREE_TYPE (src))); + niter->may_be_zero = + simplify_using_initial_conditions (loop, may_be_zero); + } else niter->may_be_zero = boolean_false_node; -- 2.30.2