https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103837
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> --- The loop body is: (code_label 10026 4 10019 3 4 (nil) [0 uses]) (note 10019 10026 5 3 [bb 3] NOTE_INSN_BASIC_BLOCK) (debug_insn 5 10019 6 3 (var_location:DF a (reg/v:DF 84 [ a ])) -1 (nil)) (debug_insn 6 5 7 3 (debug_marker) "pr103837.c":8:3 -1 (nil)) (debug_insn 7 6 17 3 (debug_marker) "pr103837.c":10:7 -1 (nil)) (debug_insn 17 7 16 3 (var_location:SI D#6 (fix:SI (reg/v:DF 84 [ a ]))) -1 (nil)) (debug_insn 16 17 15 3 (var_location:SI D#5 (debug_expr:SI D#6)) -1 (nil)) (debug_insn 15 16 14 3 (var_location:CCZ D#4 (compare:CCZ (debug_expr:SI D#5) (const_int 0 [0]))) -1 (nil)) (debug_insn 14 15 13 3 (var_location:QI D#3 (ne:QI (debug_expr:CCZ D#4) (const_int 0 [0]))) -1 (nil)) (debug_insn 13 14 12 3 (var_location:QI D#2 (debug_expr:QI D#3)) -1 (nil)) (debug_insn 12 13 8 3 (var_location:SI D#1 (zero_extend:SI (debug_expr:QI D#2))) -1 (nil)) (debug_insn 8 12 9 3 (var_location:SI b (debug_expr:SI D#1)) "pr103837.c":10:9 -1 (nil)) (debug_insn 9 8 10025 3 (debug_marker) "pr103837.c":11:7 -1 (nil)) (insn 10025 9 10 3 (set (reg/v:DF 84 [ a ]) (float:DF (reg/v:SI 88 [ x ]))) "pr103837.c":11:9 207 {*floatsidf2} (nil)) (debug_insn 10 10025 11 3 (var_location:DF a (reg/v:DF 84 [ a ])) "pr103837.c":11:9 -1 (nil)) (debug_insn 11 10 0 3 (debug_marker) "pr103837.c":8:3 -1 (nil)) and because of the uninitialized a there is a DEBUG_INSN use of pseudo 84 e.g. in insns 5 and 17 before it is actually initialized in insn 10025. Ignoring DEBUG_INSNs in can_move_invariant_reg in the for (use = DF_REG_USE_CHAIN (dest_regno); use; use = DF_REF_NEXT_REG (use)) loop is trivial, the big question is what shall we do with those debug insns. For this particular case where it is uninitialized, I bet either resetting or keeping them as is would be fine. But my understanding of can_move_invariant_reg is that we could have: pseudo = whatever1; loop_header debug_insn use pseudo; pseudo = whatever2; use pseudo; loop_end and in that case moving the invariant without resetting the debug insns would be wrong: pseudo = whatever1; pseudo = whatever2; loop_header debug_insn use pseudo; use pseudo; loop_end