https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101469
--- Comment #2 from Valeriy E. Ushakov <uwe at netbsd dot org> --- I don't have the latest gcc handy, but I see this bug already in an old netbsd tree from about an year ago with gcc 8.4.0 As hgutch@n.o pointed out, this seems to be a problem with this peephole2: ;; mov r12,r0 ;; add #-48,r0 -> add #-48,r12 ;; mov.l r0,@(4,r10) mov.l r12,@(4,r10) ;; (r12 dead) (define_peephole2 [(set (match_operand:SI 0 "arith_reg_dest") (match_operand:SI 1 "arith_reg_dest")) (set (match_dup 0) (plus:SI (match_dup 0) (match_operand:SI 2 "const_int_operand"))) (set (match_operand:SI 3 "general_movdst_operand") (match_dup 0))] as far as I can tell, it optimizes r0 = r2 r0 += 64 *(r0+4) = r0 to r2 += 64 *(r0+4) = r2 failing to notice that the the destination uses r0 too. Then in the cprop-registers step that r0 is replaced with r12 b/c of r0 = r12 done a bit earlier.