https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99863
--- Comment #12 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Ah, I see the actual problem. replace_read checks the hard regs in the insn sequence and compares them to the live hard regs at the point of the read_insn, in the testcase insn 134 after the CC setter 6 and CC users 7 and 40. CC is not live on the insn 134. But we emit that sequence elsewhere: 2076 /* Insert this right before the store insn where it will be safe 2077 from later insns that might change it before the read. */ 2078 emit_insn_before (insns, store_insn->insn); and store_insn->insn in this case is insn 19, which is in between insn 7 and 40, and CC is live there. So, I think we need to do this live hard regs testing in record_store instead or in addition to. We already call get_stored_val there just for testing purposes and throw it away afterwards.