diff options
author | Sebastian Pop <pop@cri.ensmp.fr> | 2005-06-07 19:51:25 +0000 |
---|---|---|
committer | Sebastian Pop <pop@cri.ensmp.fr> | 2005-06-07 19:51:25 +0000 |
commit | ed34ec248797e755b621f8f47c8e3ba55e5bb8bb (patch) | |
tree | 4aae0809ad1fc08b9c4dad889abab72475236b7f /gcc/tree-vrp.c | |
parent | ecab2b047b6916d7a193078664df7dac67261092 (diff) |
Fixes PR 18403 and meta PR 21861.
* Makefile.in (tree-chrec.o): Depend on CFGLOOP_H and TREE_FLOW_H.
* tree-chrec.c: Include cfgloop.h and tree-flow.h.
(evolution_function_is_invariant_rec_p,
evolution_function_is_invariant_p): New.
(chrec_convert): Use an extra parameter AT_STMT for refining the
information that is passed down to convert_step. Integrate the
code that was in count_ev_in_wider_type.
* tree-chrec.h (count_ev_in_wider_type): Removed.
(chrec_convert): Modify its declaration.
(evolution_function_is_invariant_p): Declared.
(evolution_function_is_affine_p): Use evolution_function_is_invariant_p.
* tree-flow.h (can_count_iv_in_wider_type): Renamed convert_step.
(scev_probably_wraps_p): Declared.
* tree-scalar-evolution.c (count_ev_in_wider_type): Removed.
(follow_ssa_edge_in_rhs, interpret_rhs_modify_expr):
Use an extra parameter AT_STMT for refining the information that is
passed down to convert_step.
(follow_ssa_edge_inner_loop_phi, follow_ssa_edge,
analyze_scalar_evolution_1): Initialize AT_STMT with the current
analyzed statement.
(instantiate_parameters_1): Don't know yet how to initialize AT_STMT.
* tree-ssa-loop-ivopts.c (idx_find_step): Update the use of
can_count_iv_in_wider_type to use convert_step.
* tree-ssa-loop-niter.c (can_count_iv_in_wider_type_bound): Move
code that is independent of the loop over the known iteration
bounds to convert_step_widening, the rest is moved to
proved_non_wrapping_p.
(scev_probably_wraps_p): New.
(can_count_iv_in_wider_type): Renamed convert_step.
* tree-vrp.c (adjust_range_with_scev): Take an extra AT_STMT parameter.
Use scev_probably_wraps_p for computing init_is_max.
(vrp_visit_assignment): Pass the current analyzed statement to
adjust_range_with_scev.
(execute_vrp): Call estimate_numbers_of_iterations for refining the
information provided by scev analyzer.
testsuite:
* testsuite/gcc.dg/vect/vect-77.c: Remove xfail from lp64.
* testsuite/gcc.dg/vect/vect-78.c: Same.
git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@100718 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-vrp.c')
-rw-r--r-- | gcc/tree-vrp.c | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 373e8d93135..b42da82612a 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -1427,13 +1427,13 @@ extract_range_from_expr (value_range_t *vr, tree expr) set_value_range_to_varying (vr); } - -/* Given a range VR, a loop L and a variable VAR, determine whether it +/* Given a range VR, a LOOP and a variable VAR, determine whether it would be profitable to adjust VR using scalar evolution information for VAR. If so, update VR with the new limits. */ static void -adjust_range_with_scev (value_range_t *vr, struct loop *l, tree var) +adjust_range_with_scev (value_range_t *vr, struct loop *loop, tree stmt, + tree var) { tree init, step, chrec; bool init_is_max; @@ -1443,7 +1443,7 @@ adjust_range_with_scev (value_range_t *vr, struct loop *l, tree var) if (vr->type == VR_ANTI_RANGE) return; - chrec = analyze_scalar_evolution (l, var); + chrec = analyze_scalar_evolution (loop, var); if (TREE_CODE (chrec) != POLYNOMIAL_CHREC) return; @@ -1455,22 +1455,12 @@ adjust_range_with_scev (value_range_t *vr, struct loop *l, tree var) if (!is_gimple_min_invariant (step)) return; - /* FIXME. When dealing with unsigned types, - analyze_scalar_evolution sets STEP to very large unsigned values - when the evolution goes backwards. This confuses this analysis - because we think that INIT is the smallest value that the range - can take, instead of the largest. Ignore these chrecs for now. */ - if (INTEGRAL_TYPE_P (TREE_TYPE (step)) && TYPE_UNSIGNED (TREE_TYPE (step))) - return; - - /* Do not adjust ranges when using wrapping arithmetic. */ - if (flag_wrapv) + /* Do not adjust ranges when chrec may wrap. */ + if (scev_probably_wraps_p (chrec_type (chrec), init, step, stmt, + cfg_loops->parray[CHREC_VARIABLE (chrec)], + &init_is_max)) return; - /* If STEP is negative, then INIT is the maximum value the range - will take. Otherwise, INIT is the minimum value. */ - init_is_max = (tree_int_cst_sgn (step) < 0); - if (!POINTER_TYPE_P (TREE_TYPE (init)) && (vr->type == VR_VARYING || vr->type == VR_UNDEFINED)) { @@ -2772,7 +2762,7 @@ vrp_visit_assignment (tree stmt, tree *output_p) else about the range of LHS by examining scalar evolution information. */ if (cfg_loops && (l = loop_containing_stmt (stmt))) - adjust_range_with_scev (&new_vr, l, lhs); + adjust_range_with_scev (&new_vr, l, stmt, lhs); if (update_value_range (lhs, &new_vr)) { @@ -3519,7 +3509,10 @@ execute_vrp (void) cfg_loops = loop_optimizer_init (NULL); if (cfg_loops) - scev_initialize (cfg_loops); + { + scev_initialize (cfg_loops); + estimate_numbers_of_iterations (cfg_loops); + } vrp_initialize (); ssa_propagate (vrp_visit_stmt, vrp_visit_phi_node); |