https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64317
--- Comment #17 from Jeffrey A. Law <law at redhat dot com> --- Thanks Vlad, that patch helped. Prior to your patch we had 15 reloads of the PIC register from memory, after your patch we have just 9. However, several of the remaining 9 seem to be redundant. LRA never considers a block starting with a label as participating in an EBB. That's overly conservative. A block can participate in an EBB if all of its predecessors are part of the same EBB. That's particularly useful in CFGs like A /| / | B | \ | \| C [ Flow downward of course. ] If we assume that B is the fallthru path, then LRA will try to make AB into an EBB. But it will not consider C because C will start with a label. That ultimately causes missed inheritances in this example. As an example, we have this in the .reload dump: [ BB 7 ] (insn 848 94 582 7 (set (reg:SI 6 bp [107]) (mem/c:SI (plus:SI (reg/f:SI 7 sp) (const_int 28 [0x1c])) [4 %sfp+-4 S4 A32])) k.c:22 90 {*movsi_internal} (nil)) [ ... ] (jump_insn 99 98 100 7 (set (pc) (if_then_else (geu (reg:CC 17 flags) (const_int 0 [0])) (label_ref 103) (pc))) k.c:18 613 {*jcc_1} (int_list:REG_BR_PROB 5000 (nil)) [ BB 8 ] (insn 584 100 101 8 (set (reg:SI 3 bx [107]) (reg:SI 6 bp [107])) k.c:19 90 {*movsi_internal} (nil)) [ Note we inherited the value in %ebp, this is good. ] [ ... ] [ BB 9 ] (code_label 103 102 104 9 5 "" [1 uses]) [ ... ] (insn 850 105 585 9 (set (reg:SI 6 bp [107]) (mem/c:SI (plus:SI (reg/f:SI 7 sp) (const_int 28 [0x1c])) [4 %sfp+-4 S4 A32])) k.c:22 90 {*movsi_internal} (nil)) Note insn 850 which reloads the value from memory again. We correctly formed an EBB with BB7 and BB8, but we really should have extended that to BB9. It appears that fixing this would improve things further. It's also the case that the post-reload passes aren't doing as good of a job at cleaning things up as they should, so I'll look at that in parallel if you can investigate the LRA side of things.