This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC] make expensive mflr be away from its user in the function prologue
ClosedPublic

Authored by shchenz on Nov 4 2022, 7:16 AM.

Details

Summary

mflr is kind of expensive on Power version smaller than 10, so we should schedule the store for the mflr's def away from mflr.

In epilogue, the expensive mtlr has no user for its def, so it doesn't matter that the load and the mtlr are back-to-back.

Diff Detail

Event Timeline

shchenz created this revision.Nov 4 2022, 7:16 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 4 2022, 7:16 AM
shchenz requested review of this revision.Nov 4 2022, 7:16 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 4 2022, 7:16 AM
shchenz edited the summary of this revision. (Show Details)Nov 4 2022, 7:25 AM
RolandF added inline comments.Nov 7 2022, 7:59 AM
llvm/lib/Target/PowerPC/PPCFrameLowering.cpp
621

The cost of an mflr is a characteristic of an implementation, not of the architecture. A future processor might have a slow mflr. I think a new subtarget feature is needed for this.

shchenz updated this revision to Diff 473874.Nov 7 2022, 10:03 PM
shchenz retitled this revision from [PowerPC][WIP] make expensive mflr be awfy from its user in the function prologue to [PowerPC] make expensive mflr be away from its user in the function prologue.

fix all LIT failures

shchenz marked an inline comment as done.
shchenz added inline comments.
llvm/lib/Target/PowerPC/PPCFrameLowering.cpp
621

I added a new patch https://reviews.llvm.org/D137612 to add the subtarget feature. Seems for P10, the latency for mflr is only 2 cycles, so I only set the new feature for P10.

shchenz updated this revision to Diff 474124.Nov 8 2022, 5:33 PM
shchenz marked an inline comment as done.
shchenz edited the summary of this revision. (Show Details)Nov 10 2022, 6:30 PM
This revision is now accepted and ready to land.Nov 14 2022, 10:05 AM
This revision was landed with ongoing or failed builds.Nov 14 2022, 6:14 PM
This revision was automatically updated to reflect the committed changes.