------- Comment #12 from rguenth at gcc dot gnu dot org 2007-07-04 10:16 ------- This is SCEV. From
<L2>:; i_7 = ASSERT_EXPR <i_20, i_20 > 4>; i.10_10 = (unsigned int) i_7; D.2489_11 = i.10_10 - 7; if (D.2489_11 <= 2) goto <L3>; else goto <L4>; we have Found new range for i.10_10: [5, 12] Visiting statement: D.2489_11 = i.10_10 - 7; (analyze_scalar_evolution (loop_nb = 1) (scalar = D.2489_11) (get_scalar_evolution (scalar = D.2489_11) (scalar_evolution = {4294967290, +, 1}_1)) (set_scalar_evolution (scalar = D.2489_11) (scalar_evolution = {4294967290, +, 1}_1)) ) (instantiate_parameters (loop_nb = 1) (chrec = {4294967290, +, 1}_1) (res = {4294967290, +, 1}_1)) Found new range for D.2489_11: [4294967290, +INF] which is wrong. The new range should be ~[5, 4294967290]. scev_probably_wraps_p() returns false for the above chrec because for the loop in question estimated_nb_iterations is 4(!) which is derived from infer_loop_bounds_from_undefined. On the trunk this is fixed by rewriting number of iterations analysis. On the 4.2 branch we can fix this conservatively by Index: tree-ssa-loop-niter.c =================================================================== --- tree-ssa-loop-niter.c (revision 126260) +++ tree-ssa-loop-niter.c (working copy) @@ -1747,6 +1747,12 @@ infer_loop_bounds_from_undefined (struct { bb = bbs[i]; + /* If BB is not executed in each iteration of the loop, we cannot + use the operations in it to infer reliable upper bound on the + # of iterations of the loop. */ + if (!dominated_by_p (CDI_DOMINATORS, loop->latch, bb)) + continue; + for (bsi = bsi_start (bb); !bsi_end_p (bsi); bsi_next (&bsi)) { tree stmt = bsi_stmt (bsi); I'm going to test this. -- rguenth at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- AssignedTo|unassigned at gcc dot gnu |rguenth at gcc dot gnu dot |dot org |org Status|NEW |ASSIGNED Last reconfirmed|2007-06-26 10:45:47 |2007-07-04 10:16:51 date| | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32500