This is an archive of the discontinued LLVM Phabricator instance.

RAGreedyStats: Ignore identity COPYs; count COPYs from/to physregs
ClosedPublic

Authored by MatzeB on Aug 15 2022, 5:42 PM.

Details

Summary

Improve copy statistics:

  • Count copies from or to physical registers: They are used to model function parameters and calling conventions and the register allocator optimizes for them.
  • Check physical registers assigned to virtual registers and stop counting "identity" COPYs where source and destination is the same physical registers; they will be removed in the virtregmap pass anyway.

Diff Detail

Event Timeline

MatzeB created this revision.Aug 15 2022, 5:42 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 15 2022, 5:42 PM
MatzeB requested review of this revision.Aug 15 2022, 5:42 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 15 2022, 5:42 PM
MatzeB added a comment.EditedAug 15 2022, 5:44 PM

Thinking about this some more, we should start counting COPYs from PhysReg->VirtReg and VirtReg->PhysReg though... Will adapt this...

MatzeB retitled this revision from Do not count identity copies for register allocation costs to RAGreedyStats: Do not count identity copies for register allocation costs.Aug 15 2022, 5:52 PM
MatzeB updated this revision to Diff 452865.Aug 15 2022, 6:19 PM
MatzeB retitled this revision from RAGreedyStats: Do not count identity copies for register allocation costs to RAGreedyStats: Ignore identidy COPYs; count COPYs from/to physregs.
MatzeB edited the summary of this revision. (Show Details)

Updated to also count COPYs from/to physical registers.

llvm/lib/CodeGen/RegAllocGreedy.cpp
2374

Note for reviewers: We don't need the isReg() check as COPYs are only allowed between register operands.

MatzeB retitled this revision from RAGreedyStats: Ignore identidy COPYs; count COPYs from/to physregs to RAGreedyStats: Ignore identity COPYs; count COPYs from/to physregs.Aug 15 2022, 6:26 PM
mtrofin accepted this revision.Aug 15 2022, 7:36 PM
mtrofin added inline comments.
llvm/lib/CodeGen/RegAllocGreedy.cpp
2377

nit: how about:

if (SrcReg.isVirtual()) {
  ...
}
if (DestReg.isVirtual()) {
  ...
}
Stats.Copies += (SrcReg != DestReg);
This revision is now accepted and ready to land.Aug 15 2022, 7:36 PM
skatkov accepted this revision.Aug 15 2022, 10:02 PM
thegameg accepted this revision.Aug 15 2022, 10:11 PM
mtrofin added inline comments.Aug 16 2022, 4:21 AM
llvm/lib/CodeGen/RegAllocGreedy.cpp
2377

Oh, never mind, incorrect suggestion.

MatzeB updated this revision to Diff 453044.Aug 16 2022, 9:33 AM
MatzeB updated this revision to Diff 453148.Aug 16 2022, 4:03 PM
This revision was landed with ongoing or failed builds.Aug 17 2022, 12:55 PM
This revision was automatically updated to reflect the committed changes.