[Bug tree-optimization/113385] [14 regression] ICE when building opencv (dfs_enumerate_from, at cfganal.cc:1590)

2024-01-15 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113385

Richard Biener  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #7 from Richard Biener  ---
Should be fixed.

[Bug tree-optimization/113385] [14 regression] ICE when building opencv (dfs_enumerate_from, at cfganal.cc:1590)

2024-01-15 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113385

--- Comment #6 from GCC Commits  ---
The master branch has been updated by Richard Biener :

https://gcc.gnu.org/g:afac1bd33657a5054f5e6ea6746c25bbb70b82f2

commit r14-7243-gafac1bd33657a5054f5e6ea6746c25bbb70b82f2
Author: Richard Biener 
Date:   Mon Jan 15 10:03:59 2024 +0100

tree-optimization/113385 - wrong loop father with early exit vectorization

The following avoids splitting an edge before redirecting it.  This
allows the loop father of the new block to be correct in the first
place.

PR tree-optimization/113385
* tree-vect-loop-manip.cc (slpeel_tree_duplicate_loop_to_edge_cfg):
First redirect, then split the exit edge.

[Bug tree-optimization/113385] [14 regression] ICE when building opencv (dfs_enumerate_from, at cfganal.cc:1590)

2024-01-15 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113385

--- Comment #5 from Andrew Pinski  ---
Created attachment 57080
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57080&action=edit
Further reduced

Reduced further, removes the warnings too.

Still has so many C++ layers in it though.

[Bug tree-optimization/113385] [14 regression] ICE when building opencv (dfs_enumerate_from, at cfganal.cc:1590)

2024-01-15 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113385

Richard Biener  changed:

   What|Removed |Added

   Last reconfirmed||2024-01-15
   Priority|P3  |P1
 Ever confirmed|0   |1
 Status|UNCONFIRMED |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |rguenth at gcc dot 
gnu.org

--- Comment #4 from Richard Biener  ---
Confirmed.  The ICE means that loop->num_nodes is out-of-date.

I see an early exit created BB which is in the wrong loop.  This:

  for (auto exit : loop_exits)
{ 
  basic_block dest = main_loop_exit_block;
  if (exit != loop_exit)
{
  if (!alt_loop_exit_block)
{
  alt_loop_exit_block = split_edge (exit);

splits an edge to __assert_fail but is then re-wried

  edge res = redirect_edge_and_branch (
single_succ_edge (alt_loop_exit_block),
new_preheader);
  flush_pending_stmts (res);
  continue;

not sure why we split the edge before redirecting, swapping fixes the
testcase.  remove_bb_from_loops/add_bb_to_loop could also fixup with
the original order.

I'm testing swapping.

[Bug tree-optimization/113385] [14 regression] ICE when building opencv (dfs_enumerate_from, at cfganal.cc:1590)

2024-01-14 Thread sjames at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113385

--- Comment #3 from Sam James  ---
Created attachment 57078
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57078&action=edit
reduced.ii

Attached something a bit smaller but it's not great (not very elegant and too
many warnings).

[Bug tree-optimization/113385] [14 regression] ICE when building opencv (dfs_enumerate_from, at cfganal.cc:1590)

2024-01-13 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113385

--- Comment #2 from Andrew Pinski  ---
Fuller backtrace:
```
#2  0x0083f554 in dfs_enumerate_from (bb=,
reverse=reverse@entry=1, predicate=predicate@entry=0xe00620
, rslt=,
rslt@entry=0x4604c70, rslt_max=36, data=data@entry=0x7fffddb02960)
at /home/apinski/src/upstream-gcc-match/gcc/gcc/cfganal.cc:1590
#3  0x00e01272 in get_loop_body_with_size (max_size=,
body=0x4604c70, loop=0x7fffddb02960) at
/home/apinski/src/upstream-gcc-match/gcc/gcc/cfgloop.cc:872
#4  get_loop_body (loop=loop@entry=0x7fffddb02960) at
/home/apinski/src/upstream-gcc-match/gcc/gcc/cfgloop.cc:901
#5  0x014d0bea in estimate_numbers_of_iterations (loop=0x7fffddb02960)
at /home/apinski/src/upstream-gcc-match/gcc/gcc/tree-ssa-loop-niter.cc:4833
#6  0x014d4616 in loop_exits_before_overflow (loop=0x7fffddb02960,
at_stmt=0x7fffd7d63d20, step=0x74314f48, base=0x776603a8) at
/home/apinski/src/upstream-gcc-match/gcc/gcc/tree-ssa-loop-niter.cc:5259
#7  scev_probably_wraps_p (var=var@entry=0x0, base=base@entry=0x776603a8,
step=step@entry=0x74314f48, at_stmt=0x7fffd7d63d20,
loop=loop@entry=0x7fffddb02960,
use_overflow_semantics=use_overflow_semantics@entry=false) at
/home/apinski/src/upstream-gcc-match/gcc/gcc/tree-ssa-loop-niter.cc:5511
#8  0x02462fff in convert_affine_scev (loop=0x7fffddb02960,
type=, base=0x7fffc1d0, step=0x7fffc1d8,
at_stmt=, use_overflow_semantics=,
from=0x7fffd814b708) at
/home/apinski/src/upstream-gcc-match/gcc/gcc/tree-chrec.cc:1425
#9  0x02462a59 in chrec_convert_1 (type=0x77826738,
chrec=0x7fffd7d819b0, at_stmt=0x7fffd7d63d20, use_overflow_semantics=, from=0x7fffd814b708) at
/home/apinski/src/upstream-gcc-match/gcc/gcc/tree-chrec.cc:1483
#10 0x0141b887 in interpret_gimple_assign (stmt=0x7fffd7d63d20,
loop=0x7fffddb02960) at
/home/apinski/src/upstream-gcc-match/gcc/gcc/tree-scalar-evolution.cc:1919
#11 analyze_scalar_evolution_1 (loop=0x7fffddb02960, var=0x7fffd8130828) at
/home/apinski/src/upstream-gcc-match/gcc/gcc/tree-scalar-evolution.cc:1970
#12 0x0141c193 in analyze_scalar_evolution (loop=0x7fffddb02960,
var=0x7fffd8130828) at
/home/apinski/src/upstream-gcc-match/gcc/gcc/tree-scalar-evolution.cc:2039
#13 0x0141eceb in analyze_scalar_evolution_in_loop
(wrto_loop=wrto_loop@entry=0x7fffddb02960,
use_loop=use_loop@entry=0x7fffddb02960, version=,
folded_casts=folded_casts@entry=0x7fffc37b) at
/home/apinski/src/upstream-gcc-match/gcc/gcc/tree-scalar-evolution.cc:2165
#14 0x01420696 in simple_iv_with_niters (wrto_loop=0x7fffddb02960,
use_loop=0x7fffddb02960, op=, iv=0x7fffc480, iv_niters=0x0,
allow_nonconstant_step=false) at
/home/apinski/src/upstream-gcc-match/gcc/gcc/tree-scalar-evolution.cc:3237
#15 0x014c2c02 in get_cst_init_from_scev (var=var@entry=0x7fffd8130828,
init=init@entry=0x7fffc580, is_min=is_min@entry=true) at
/home/apinski/src/upstream-gcc-match/gcc/gcc/tree-ssa-loop-niter.cc:4015
#16 0x014c64f0 in record_nonwrapping_iv (loop=0x7fffddaf0320,
base=0x7fffe6031d00, step=0x7692fbb8, stmt=0x7fffd8121cb8,
low=0x776603a8, high=, upper=true, realistic=false) at
/home/apinski/src/upstream-gcc-match/gcc/gcc/tree-ssa-loop-niter.cc:4101
#17 0x014c6bb9 in infer_loop_bounds_from_signedness
(loop=0x7fffddaf0320, stmt=0x7fffd8121cb8) at
/home/apinski/src/upstream-gcc-match/gcc/gcc/tree-ssa-loop-niter.cc:4380
#18 0x014d21c3 in infer_loop_bounds_from_undefined (bbs=, loop=) at
/home/apinski/src/upstream-gcc-match/gcc/gcc/tree-ssa-loop-niter.cc:4418
#19 estimate_numbers_of_iterations (loop=0x7fffddaf0320) at
/home/apinski/src/upstream-gcc-match/gcc/gcc/tree-ssa-loop-niter.cc:4872
#20 0x014d3f38 in estimated_loop_iterations (nit=0x7fffd340,
loop=0x7fffddaf0320) at
/home/apinski/src/upstream-gcc-match/gcc/gcc/tree-ssa-loop-niter.cc:4904
#21 estimated_loop_iterations_int (loop=loop@entry=0x7fffddaf0320) at
/home/apinski/src/upstream-gcc-match/gcc/gcc/tree-ssa-loop-niter.cc:4919
#22 0x014d3f69 in estimated_stmt_executions_int
(loop=loop@entry=0x7fffddaf0320) at
/home/apinski/src/upstream-gcc-match/gcc/gcc/tree-ssa-loop-niter.cc:5007
#23 0x015e1c58 in vect_analyze_loop_costing (loop_vinfo=, suggested_unroll_factor=) at
/home/apinski/src/upstream-gcc-match/gcc/gcc/tree-vect-loop.cc:2450
#24 0x015ee8df in vect_analyze_loop_2 (loop_vinfo=,
fatal=, suggested_unroll_factor=0x7fffd83c,
slp_done_for_suggested_uf=@0x7fffd83b: false) at
/home/apinski/src/upstream-gcc-match/gcc/gcc/tree-vect-loop.cc:3187
#25 0x015f050f in vect_analyze_loop_1 (loop=0x7fffddaf0320,
shared=0x7fffda70, loop_form_info=0x7fffd900, main_loop_vinfo=0x0,
vector_modes=..., mode_i=@0x7fffd8dc: 0,
autodetected_vector_mode=@0x7fffd8d8: E_VOIDmode, fatal=@0x7fffd8d7:
false)
at /home/apinski/src/upstream-gcc-match/gcc/gcc/tree-vect-loop.cc:3482
#26 0x015f0d38 in vect_analyze_loop

[Bug tree-optimization/113385] [14 regression] ICE when building opencv (dfs_enumerate_from, at cfganal.cc:1590)

2024-01-13 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113385

Andrew Pinski  changed:

   What|Removed |Added

   Target Milestone|--- |14.0
   Keywords||ice-on-valid-code

[Bug tree-optimization/113385] [14 regression] ICE when building opencv (dfs_enumerate_from, at cfganal.cc:1590)

2024-01-13 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113385

--- Comment #1 from Andrew Pinski  ---
Reducing ...