[Bug tree-optimization/112636] [14 Regression] ICE on valid code at -O1 (but not at -O{0,s,2,3}) with "-ftree-vectorize": in adjust_loop_info_after_peeling, at tree-ssa-loop-ivcanon.cc:1069
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112636 Richard Biener changed: What|Removed |Added Resolution|--- |FIXED Status|ASSIGNED|RESOLVED --- Comment #4 from Richard Biener --- Fixed.
[Bug tree-optimization/112636] [14 Regression] ICE on valid code at -O1 (but not at -O{0,s,2,3}) with "-ftree-vectorize": in adjust_loop_info_after_peeling, at tree-ssa-loop-ivcanon.cc:1069
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112636 --- Comment #3 from GCC Commits --- The master branch has been updated by Richard Biener : https://gcc.gnu.org/g:05e8ef2a05b477589cae25af3311bad0f68a90fe commit r14-7138-g05e8ef2a05b477589cae25af3311bad0f68a90fe Author: Richard Biener Date: Thu Jan 11 13:35:51 2024 +0100 tree-optimization/112636 - estimate niters before header copying The following avoids a mismatch between an early query for maximum number of iterations of a loop and a late one when through ranger we'd get iterations estimated. Instead make sure we compute niters before querying the iteration bound. PR tree-optimization/112636 * tree-ssa-loop-ch.cc (ch_base::copy_headers): Call estimate_numbers_of_iterations before querying get_max_loop_iterations_int. (pass_ch::execute): Initialize SCEV and loops appropriately. * gcc.dg/pr112636.c: New testcase.
[Bug tree-optimization/112636] [14 Regression] ICE on valid code at -O1 (but not at -O{0,s,2,3}) with "-ftree-vectorize": in adjust_loop_info_after_peeling, at tree-ssa-loop-ivcanon.cc:1069
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112636 Richard Biener 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 --- 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=0x7700e4b0) at /space/rguenther/src/gcc/gcc/tree-ssa-loop-niter.cc:4806 #1 0x019434ef in loop_exits_before_overflow ( base=, step=, at_stmt=, loop=0x7700e4b0) at /space/rguenther/src/gcc/gcc/tree-ssa-loop-niter.cc:5259 #2 0x019440b0 in scev_probably_wraps_p (var=, base=, step=, at_stmt=, loop=0x7700e4b0, use_overflow_semantics=true) at /space/rguenther/src/gcc/gcc/tree-ssa-loop-niter.cc:5511 #3 0x01bb97ea in get_scev_info (r=..., name=, stmt=, l=0x7700e4b0, init=@0x7fffa898: , step=@0x7fffa890: , dir=@0x7fffa88c: EV_DIR_DECREASES) at /space/rguenther/src/gcc/gcc/vr-values.cc:204 #4 0x01bb9d6d in range_of_var_in_loop (v=..., name=, l=0x7700e4b0, stmt=, query=0x4961550) at /space/rguenther/src/gcc/gcc/vr-values.cc:271 #5 0x02edf824 in fold_using_range::range_of_ssa_name_with_loop_info ( this=0x7fffb46f, r=..., name=, ... #22 0x018f3f77 in should_duplicate_loop_header_p ( header=, loop=0x7700e4b0, ranger=0x4961550, limit=0x7fffd88c, invariant_exits=0x47e60f0, static_exits=0x4961040) at /space/rguenther/src/gcc/gcc/tree-ssa-loop-ch.cc:251 #23 0x018f59d7 in (anonymous namespace)::ch_base::copy_headers ( this=0x47f2a30, fun=0x771e2000) 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.
[Bug tree-optimization/112636] [14 Regression] ICE on valid code at -O1 (but not at -O{0,s,2,3}) with "-ftree-vectorize": in adjust_loop_info_after_peeling, at tree-ssa-loop-ivcanon.cc:1069
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112636 Richard Biener changed: What|Removed |Added Target Milestone|--- |14.0 CC||hubicka at gcc dot gnu.org Keywords||ice-on-valid-code, ||missed-optimization Priority|P3 |P1 Version|unknown |14.0 Status|UNCONFIRMED |NEW Last reconfirmed||2023-11-20 Summary|ICE on valid code at -O1|[14 Regression] ICE on |(but not at -O{0,s,2,3})|valid code at -O1 (but not |with "-ftree-vectorize": in |at -O{0,s,2,3}) with |adjust_loop_info_after_peel |"-ftree-vectorize": in |ing, at |adjust_loop_info_after_peel |tree-ssa-loop-ivcanon.cc:10 |ing, at |69 |tree-ssa-loop-ivcanon.cc:10 ||69 Ever confirmed|0 |1 --- Comment #1 from Richard Biener --- Confirmed. if (wi::leu_p (npeel, loop->nb_iterations_upper_bound)) loop->nb_iterations_upper_bound -= npeel; else { /* Peeling maximal number of iterations or more makes no sense and is a bug. We should peel completely. */ gcc_unreachable (); so we're asking to adjust for peeling of 1 iteration with an upper bound of iterations of zero. We derive this limit from the array size of a[]. Caused by Honzas loop header copying changes.