[PATCH] D150673: [XCore] Use backwards scavenging in frame index elimination

Jay Foad via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 16 08:25:53 PDT 2023

foad added a comment.

The lit test shows increased spilling/reloading of scavenged registers. Previously it was:

  spill r4
    use r4
  spill r5
    use r4 and r5
    use r5
  reload r4
  reload r5

Now it is:

  spill r0
    use r0
  reload r0
  spill r1
  spill r2
    use r1 and r2
  reload r2
  reload r1
  spill r2
    use r2
  reload r2

@fhahn this is because `RegScavenger::findSurvivorReg`[forwards] returns with a "restore point" as late as possible, but `findSurvivorBackwards` does not return with a "spill before" point as early as possible. It only chooses the earlier `To` and the earliest vreg operand it saw.

I assume the special handling of vreg operands is because it was designed to be used for `PrologEpilogInserter::doScavengeFrameVirtualRegs` (D21885 <https://reviews.llvm.org/D21885>). Now that it is being used for frame index elimination too, would it make sense to handle frame index operands similarly?

  rG LLVM Github Monorepo



More information about the llvm-commits mailing list