https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112636

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot 
gnu.org
             Status|NEW                         |ASSIGNED

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
The issue is that should_duplicate_loop_header_p we call after

      basic_block header = loop->header;
      if (!get_max_loop_iterations_int (loop))
        {
          if (dump_file && (dump_flags & TDF_DETAILS))
            fprintf (dump_file, "Loop %d never loops.\n", loop->num);
          scale_loop_profile (loop, profile_probability::always (), 0);
          loops_to_unloop.safe_push (loop);
          loops_to_unloop_nunroll.safe_push (0);
          continue;

ends up calling estimate_numbers_of_iterations () only then actually
updating the upper bound we check above.  It does so hidden via

#0  estimate_numbers_of_iterations (loop=0x7ffff700e4b0)
    at /space/rguenther/src/gcc/gcc/tree-ssa-loop-niter.cc:4806
#1  0x00000000019434ef in loop_exits_before_overflow (
    base=<ssa_name 0x7ffff71e5120 8>, step=<integer_cst 0x7ffff702d180>, 
    at_stmt=<gimple_phi 0x7ffff71bb700>, loop=0x7ffff700e4b0)
    at /space/rguenther/src/gcc/gcc/tree-ssa-loop-niter.cc:5259
#2  0x00000000019440b0 in scev_probably_wraps_p (var=<tree 0x0>, 
    base=<ssa_name 0x7ffff71e5120 8>, step=<integer_cst 0x7ffff702d180>, 
    at_stmt=<gimple_phi 0x7ffff71bb700>, loop=0x7ffff700e4b0, 
    use_overflow_semantics=true)
    at /space/rguenther/src/gcc/gcc/tree-ssa-loop-niter.cc:5511
#3  0x0000000001bb97ea in get_scev_info (r=..., 
    name=<ssa_name 0x7ffff7016f78 4>, stmt=<gimple_phi 0x7ffff71bb700>, 
    l=0x7ffff700e4b0, init=@0x7fffffffa898: <ssa_name 0x7ffff71e5120 8>, 
    step=@0x7fffffffa890: <integer_cst 0x7ffff702d180>, 
    dir=@0x7fffffffa88c: EV_DIR_DECREASES)
    at /space/rguenther/src/gcc/gcc/vr-values.cc:204
#4  0x0000000001bb9d6d in range_of_var_in_loop (v=..., 
    name=<ssa_name 0x7ffff7016f78 4>, l=0x7ffff700e4b0, 
    stmt=<gimple_phi 0x7ffff71bb700>, query=0x4961550)
    at /space/rguenther/src/gcc/gcc/vr-values.cc:271
#5  0x0000000002edf824 in fold_using_range::range_of_ssa_name_with_loop_info (
    this=0x7fffffffb46f, r=..., name=<ssa_name 0x7ffff7016f78 4>, 
...
#22 0x00000000018f3f77 in should_duplicate_loop_header_p (
    header=<basic_block 0x7ffff71be6c0 (4)>, loop=0x7ffff700e4b0, 
    ranger=0x4961550, limit=0x7fffffffd88c, invariant_exits=0x47e60f0, 
    static_exits=0x4961040)
    at /space/rguenther/src/gcc/gcc/tree-ssa-loop-ch.cc:251
#23 0x00000000018f59d7 in (anonymous namespace)::ch_base::copy_headers (
    this=0x47f2a30, fun=0x7ffff71e2000)
    at /space/rguenther/src/gcc/gcc/tree-ssa-loop-ch.cc:831

The best is to analyze niters for the loop we try to process.

Reply via email to