[Bug tree-optimization/122599] [16 regression] ICE when building busybox-1.36.1 at -O3
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122599 Andrew Pinski changed: What|Removed |Added Resolution|--- |FIXED Status|ASSIGNED|RESOLVED --- Comment #8 from Andrew Pinski --- Fixed.
[Bug tree-optimization/122599] [16 regression] ICE when building busybox-1.36.1 at -O3
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122599 --- Comment #7 from GCC Commits --- The trunk branch has been updated by Andrew Pinski : https://gcc.gnu.org/g:77e10b47f25d05d51a187822fe6a8366a6d68d67 commit r16-5093-g77e10b47f25d05d51a187822fe6a8366a6d68d67 Author: Andrew Pinski Date: Fri Nov 7 14:01:33 2025 -0800 sccp: Fix order of removal of phi (again) [PR122599] This time we are gimplifying the expression and call fold_stmt during the gimplification (which is fine) but since we removed the phi and the expression references ssa names in the phi indirectly, things just fall over inside the ranger. This moves the removal of the phi until gimplification happens as it might refer back to the ssa name that the phi defines. Pushed as obvious after bootstrap test on x86_64-linux-gnu. PR tree-optimization/122599 gcc/ChangeLog: * tree-scalar-evolution.cc (final_value_replacement_loop): Move the removal of the phi until after the gimplification of the final value expression. gcc/testsuite/ChangeLog: * gcc.dg/torture/pr122599-1.c: New test. Signed-off-by: Andrew Pinski
[Bug tree-optimization/122599] [16 regression] ICE when building busybox-1.36.1 at -O3
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122599 --- Comment #6 from Andrew Pinski --- Created attachment 62737 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=62737&action=edit Reduced slightly
[Bug tree-optimization/122599] [16 regression] ICE when building busybox-1.36.1 at -O3
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122599 Andrew Pinski changed: What|Removed |Added Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |pinskia at gcc dot gnu.org --- Comment #5 from Andrew Pinski --- Yep this fixes the ICE: ``` diff --git a/gcc/tree-scalar-evolution.cc b/gcc/tree-scalar-evolution.cc index 9f82abc4b81..f5d63c74060 100644 --- a/gcc/tree-scalar-evolution.cc +++ b/gcc/tree-scalar-evolution.cc @@ -3947,11 +3947,13 @@ final_value_replacement_loop (class loop *loop) GENERIC interface). */ def = unshare_expr (def); auto loc = gimple_phi_arg_location (phi, exit->dest_idx); - remove_phi_node (&psi, false); /* Create the replacement statements. */ gimple_seq stmts; def = force_gimple_operand (def, &stmts, false, NULL_TREE); + + /* Remove the phi only after the gimplification. */ + remove_phi_node (&psi, false); gassign *ass = gimple_build_assign (rslt, def); gimple_set_location (ass, loc); gimple_seq_add_stmt (&stmts, ass); ```
[Bug tree-optimization/122599] [16 regression] ICE when building busybox-1.36.1 at -O3
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122599 Andrew Pinski changed: What|Removed |Added Last reconfirmed||2025-11-07 Status|UNCONFIRMED |NEW Ever confirmed|0 |1 --- Comment #4 from Andrew Pinski --- I think the problem is again dealing with the order here. we remove the phi before the gimplification of the expression and that is why it goes down hill. I am seeing if moving the removal of the phi after the gimplifcation fixes this one.
[Bug tree-optimization/122599] [16 regression] ICE when building busybox-1.36.1 at -O3
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122599 --- Comment #3 from Sam James --- Or maybe this is latent from the other sccp changes. I don't know, so cc'd robin as well.
[Bug tree-optimization/122599] [16 regression] ICE when building busybox-1.36.1 at -O3
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122599 Sam James changed: What|Removed |Added CC||rguenth at gcc dot gnu.org --- Comment #2 from Sam James --- ==384347== Invalid read of size 8 ==384347==at 0x62C8D08: gimple_phi_arg_edge (gimple.h:4788) ==384347==by 0x62C8D08: fold_using_range::range_of_phi(vrange&, gphi*, fur_source&) (gimple-range-fold.cc:923) ==384347==by 0x6A04251: fold_using_range::fold_stmt(vrange&, gimple*, fur_source&, tree_node*) [clone .constprop.2] (gimple-range-fold.cc:651) ==384347==by 0x62AEB51: fold_range_internal (gimple-range.cc:282) ==384347==by 0x62AEB51: gimple_ranger::prefill_stmt_dependencies(tree_node*) (gimple-range.cc:421) ==384347==by 0x62AD3AA: gimple_ranger::range_of_stmt(vrange&, gimple*, tree_node*) (gimple-range.cc:339) ==384347==by 0x627CD2E: gimple_ranger::range_of_expr(vrange&, tree_node*, gimple*) (gimple-range.cc:112) ==384347==by 0x624BDF4: ssa_name_has_boolean_range(tree_node*, gimple*) (tree-ssanames.cc:643) ==384347==by 0x61A34AC: gimple_simplify_MINUS_EXPR(gimple_match_op*, gimple**, tree_node* (*)(tree_node*), code_helper, tree_node*, tree_node*, tree_node*) [clone .constprop.0] (gimple-match-6.cc:14650) ==384347==by 0x5F9FD3F: gimple_resimplify2(gimple**, gimple_match_op*, tree_node* (*)(tree_node*)) [clone .lto_priv.0] (gimple-match-exports.cc:1020) ==384347==by 0x5F4BAA5: gimple_simplify(gimple*, gimple_match_op*, gimple**, tree_node* (*)(tree_node*), tree_node* (*)(tree_node*)) (gimple-match-exports.cc:887) ==384347==by 0x5F43BDF: fold_stmt_1(gimple_stmt_iterator*, bool, tree_node* (*)(tree_node*), bitmap_head*) [clone .lto_priv.0] (gimple-fold.cc:6747) ==384347==by 0x5F2E946: fold_stmt (gimple-fold.cc:6908) ==384347==by 0x5F2E946: maybe_fold_stmt (gimplify.cc:3925) ==384347==by 0x5F2E946: gimplify_modify_expr(tree_node**, gimple**, gimple**, bool) [clone .lto_priv.0] (gimplify.cc:7586) ==384347==by 0x5F23397: gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) (gimplify.cc:20361) ==384347== Address 0x0 is not stack'd, malloc'd or (recently) free'd ==384347== during GIMPLE pass: sccp
[Bug tree-optimization/122599] [16 regression] ICE when building busybox-1.36.1 at -O3
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122599
--- Comment #1 from Sam James ---
```
int *get_next_block_dbuf;
int get_next_block_dbufCount;
char get_next_block_tmp_byte;
int bound;
void get_next_block(unsigned runCnt) {
for (int i = 0; i < bound; i++)
while ((int)--runCnt >= 0)
get_next_block_dbuf[get_next_block_dbufCount] = get_next_block_tmp_byte;
}
```
[Bug tree-optimization/122599] [16 regression] ICE when building busybox-1.36.1 at -O3
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122599 Sam James changed: What|Removed |Added Target Milestone|--- |16.0
