https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108463
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> --- >From what I can see, the r13-5252 change removed for DEBUG_INSNs two things, one is the cselib_lookup_from_insn call with 1 as create and the other is the shallow_copy_rtx + cselib_subst_to_values_from_insn. As nothing really used t for the debug insns and cselib_subst_to_values_from_insn shouldn't create new VALUEs and the like (well, there is: /* This used to happen for autoincrements, but we deal with them properly now. Remove the if stmt for the next release. */ if (! e) { /* Assign a value that doesn't match any other. */ e = new_cselib_val (next_uid, GET_MODE (x), x); } which nobody removed so far), I think the shallow_copy_rtx + cselib_subst_to_values_from_insn are just waste of resources (allocates various rtxes nobody looks at). But the cselib_lookup_from_insn actually creates new VALUEs (and mark them as coming from DEBUG_INSNs), so I think we need to do that. E.g. in the testcase from this PR (can be even simplified to: typedef int __attribute__((__vector_size__ (32))) V; int a; void foo (V v) { a--; v = (V) v; } ) after expansion: (debug_insn 5 2 6 2 (debug_marker) "pr108463.c":7:3 -1 (nil)) (insn 6 5 7 2 (parallel [ (set (mem/c:SI (symbol_ref:DI ("a") [flags 0x2] <var_decl 0x7fb055a70cf0 a>) [1 a+0 S4 A32]) (plus:SI (mem/c:SI (symbol_ref:DI ("a") [flags 0x2] <var_decl 0x7fb055a70cf0 a>) [1 a+0 S4 A32]) (const_int -1 [0xffffffffffffffff]))) (clobber (reg:CC 17 flags)) ]) "pr108463.c":7:4 240 {*addsi_1} (nil)) (debug_insn 7 6 8 2 (debug_marker) "pr108463.c":8:3 -1 (nil)) (debug_insn 8 7 0 2 (var_location:BLK v (mem/c:BLK (reg/f:DI 16 argp) [1 v+0 S32 A256])) "pr108463.c":8:5 -1 (nil)) and before scheduling: (debug_insn 5 2 6 2 (debug_marker) "pr108463.c":7:3 -1 (nil)) (insn 6 5 7 2 (parallel [ (set (mem/c:SI (symbol_ref:DI ("a") [flags 0x2] <var_decl 0x7fb055a70cf0 a>) [1 a+0 S4 A32]) (plus:SI (mem/c:SI (symbol_ref:DI ("a") [flags 0x2] <var_decl 0x7fb055a70cf0 a>) [1 a+0 S4 A32]) (const_int -1 [0xffffffffffffffff]))) (clobber (reg:CC 17 flags)) ]) "pr108463.c":7:4 240 {*addsi_1} (expr_list:REG_UNUSED (reg:CC 17 flags) (nil))) (debug_insn 7 6 8 2 (debug_marker) "pr108463.c":8:3 -1 (nil)) (debug_insn 8 7 13 2 (var_location:BLK v (mem/c:BLK (plus:DI (reg/f:DI 7 sp) (const_int 8 [0x8])) [1 v+0 S32 A256])) "pr108463.c":8:5 -1 (nil)) (jump_insn 14 13 15 2 (simple_return) "pr108463.c":9:1 1006 {simple_return_internal} (nil) when ignoring notes. Without the cselib_lookup_from_insn call, we ICE in cselib_subst_to_values because it is the only spot in the IL that mentions the sp register, so we haven't created a VALUE for it otherwise. Unfortunately, while: --- gcc/sched-deps.cc.jj 2023-01-19 09:58:50.971227752 +0100 +++ gcc/sched-deps.cc 2023-01-26 18:11:00.185963813 +0100 @@ -2605,7 +2605,14 @@ sched_analyze_2 (class deps_desc *deps, case MEM: { - if (!DEBUG_INSN_P (insn)) + if (0 && DEBUG_INSN_P (insn) && sched_deps_info->use_cselib) + { + machine_mode address_mode = get_address_mode (x); + + cselib_lookup_from_insn (XEXP (x, 0), address_mode, 1, + GET_MODE (x), insn); + } + else if (!DEBUG_INSN_P (insn)) { /* Reading memory. */ rtx_insn_list *u; fixes this PR, it breaks again PR106746. So I think we really need to understand what is going on with PR106746.