diff options
author | Zdenek Dvorak <ook@ucw.cz> | 2007-11-30 01:32:04 +0100 |
---|---|---|
committer | Zdenek Dvorak <rakdver@gcc.gnu.org> | 2007-11-30 00:32:04 +0000 |
commit | 13285d512dac6411da329c63f6a52b81e88df7a1 (patch) | |
tree | 573fc12944ab74427d5b1d5768b2a39ac6ed4847 /gcc/tree-vrp.c | |
parent | 54bded776c12100d755e2976fbd5f1b6733ea64b (diff) | |
download | gcc-13285d512dac6411da329c63f6a52b81e88df7a1.zip gcc-13285d512dac6411da329c63f6a52b81e88df7a1.tar.gz gcc-13285d512dac6411da329c63f6a52b81e88df7a1.tar.bz2 |
re PR tree-optimization/34244 (VRP/SCEV miscompiles Firefox)
PR tree-optimization/34244
* tree-vrp.c (adjust_range_with_scev): Clear scev cache.
(record_numbers_of_iterations): New function.
(execute_vrp): Cache the numbers of iterations of loops.
* tree-scalar-evolution.c (scev_reset_except_niters):
New function.
(scev_reset): Use scev_reset_except_niters.
* tree-scalar-evolution.h (scev_reset_except_niters): Declare.
* gcc.dg/tree-ssa/pr34244.c: New test.
From-SVN: r130527
Diffstat (limited to 'gcc/tree-vrp.c')
-rw-r--r-- | gcc/tree-vrp.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 00264d9..1e1ffaa 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -2636,6 +2636,13 @@ adjust_range_with_scev (value_range_t *vr, struct loop *loop, tree stmt, if (vr->type == VR_ANTI_RANGE) return; + /* Ensure that there are not values in the scev cache based on assumptions + on ranges of ssa names that were changed + (in set_value_range/set_value_range_to_varying). Preserve cached numbers + of iterations, that were computed before the start of VRP (we do not + recompute these each time to save the compile time). */ + scev_reset_except_niters (); + chrec = instantiate_parameters (loop, analyze_scalar_evolution (loop, var)); /* Like in PR19590, scev can return a constant function. */ @@ -6047,6 +6054,20 @@ vrp_finalize (void) vr_phi_edge_counts = NULL; } +/* Calculates number of iterations for all loops, to ensure that they are + cached. */ + +static void +record_numbers_of_iterations (void) +{ + loop_iterator li; + struct loop *loop; + + FOR_EACH_LOOP (li, loop, 0) + { + number_of_latch_executions (loop); + } +} /* Main entry point to VRP (Value Range Propagation). This pass is loosely based on J. R. C. Patterson, ``Accurate Static Branch @@ -6101,6 +6122,17 @@ execute_vrp (void) insert_range_assertions (); + /* Compute the # of iterations for each loop before we start the VRP + analysis. The value ranges determined by VRP are used in expression + simplification, that is also used by the # of iterations analysis. + However, in the middle of the VRP analysis, the value ranges do not take + all the possible paths in CFG into account, so they do not have to be + correct, and the # of iterations analysis can obtain wrong results. + This is a problem, since the results of the # of iterations analysis + are cached, so these mistakes would not be corrected when the value + ranges are corrected. */ + record_numbers_of_iterations (); + vrp_initialize (); ssa_propagate (vrp_visit_stmt, vrp_visit_phi_node); vrp_finalize (); |