This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC] prepare more loop load/store instructions
ClosedPublic

Authored by shchenz on Jul 12 2021, 11:09 PM.

Details

Summary

This patch extends PPCLoopInstrFormPrep pass to prepare more ds/dq form load/store instruction for a loop.

To be specific, now PPCLoopInstrFormPrep pass now can prepare for load/store instructions in a loop whose increment is not a constant integer.

Diff Detail

Event Timeline

shchenz created this revision.Jul 12 2021, 11:09 PM
shchenz requested review of this revision.Jul 12 2021, 11:09 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 12 2021, 11:09 PM
shchenz edited the summary of this revision. (Show Details)Jul 12 2021, 11:15 PM
shchenz updated this revision to Diff 358166.Jul 12 2021, 11:18 PM

minor update for the comments

shchenz updated this revision to Diff 358807.Jul 14 2021, 6:27 PM

minor update

qiucf added a subscriber: qiucf.Jul 14 2021, 7:37 PM

Title: instrucitons -> instructions

shchenz updated this revision to Diff 358823.Jul 14 2021, 7:48 PM
shchenz retitled this revision from [PowerPC] prepare more loop load/store instrucitons to [PowerPC] prepare more loop load/store instructions.

rebase

shchenz updated this revision to Diff 358859.Jul 15 2021, 1:07 AM

handle more cases

shchenz added inline comments.Jul 15 2021, 1:29 AM
llvm/test/CodeGen/PowerPC/lsr-profitable-chain.ll
9

This would be a FIXME. This series of patches will common out multiples chains for load/stores even with same common base and with non-const increment.

This patch is the first one to make pass PPCLoopInstFormPrep prepare load/stores with non-const increment.

The next patches will be: select multiple common addresses which can make the different chains(based on different common addresses) reuse same offsets, thus we can reduce register pressure.

shchenz added inline comments.Jul 15 2021, 1:37 AM
llvm/test/CodeGen/PowerPC/lsr-profitable-chain.ll
9

Another note for this regression, it does not break the case's original intention. Even with the register pressure regression, the load instructions in the nested loop are all still with dform.

gentle ping

jsji added inline comments.Aug 31 2021, 10:45 AM
llvm/lib/Target/PowerPC/PPCLoopInstrFormPrep.cpp
172

Please commit these unrelated formatting changes directly then rebase. Thanks.

538

incresement typo?

543–548

Update comments to describe the forms we can prepare now.

755

Add comments about early exits, please.

771

Comments about this lambda please.

776

Not sure why we need this check? Do you have examples that may cost us compile time?

782

Can these two whiles be merged into one similar to:

while ((BC = dyn_cast<Instruction>(StrippedBasePtr)) &&
       BC->getOpcode() == Instruction::BitCast && BC->hasOneUser )
  StrippedI = BC->getOperand(0);
821

Why not use early exit here?

825

Why not use early exit here?

829

Recursive call?! I think we normally don't use recursive code in LLVM. Please convert it into a worklist. Thanks

shchenz updated this revision to Diff 370159.Sep 1 2021, 10:12 PM
shchenz marked 9 inline comments as done.

address @jsji comments and rebase

@jsji thanks very much for the review and also for the NFC patch https://reviews.llvm.org/D109083. Updated and rebased accordingly.

llvm/lib/Target/PowerPC/PPCLoopInstrFormPrep.cpp
172
771

I simplify the logic a little bit, so the lambda function is not needed now.

776

Now I use PHI node's operand instead of its user, so we don't have such issue any more.

shchenz updated this revision to Diff 371774.Sep 9 2021, 9:06 PM

address @jsji offline comments and rebase

jsji accepted this revision as: jsji.Sep 13 2021, 7:44 AM

LGTM. Thanks.

This revision is now accepted and ready to land.Sep 13 2021, 7:44 AM
This revision was automatically updated to reflect the committed changes.