This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC] Disable perfect shuffle by default
ClosedPublic

Authored by qiucf on Mar 6 2022, 7:14 PM.

Details

Reviewers
nemanjai
jsji
shchenz
Group Reviewers
Restricted Project
Commits
rG300e1293de63: [PowerPC] Disable perfect shuffle by default
Summary

We are going to remove the old 'perfect shuffle' optimization since it brings performance penalty in hot loop around vectors.

For example, in following loop sharing the same mask:

%v.1 = shufflevector %x.1, %y.1, <0, 1, 2, 3, 8, 9, 10, 11, 16, 17, 18, 19, 24, 25, 26, 27>
%v.2= shufflevector %x.2, %y.2, <0, 1, 2, 3, 8, 9, 10, 11, 16, 17, 18, 19, 24, 25, 26, 27>
...

The instruction result would be:

vmrglw ...
vmrghw ...
vmrglw ...
vmrghw ...

instead of

vperm
vperm
...

In some large loop cases, this causes 20%+ performance downgradation. In perfect-shuffle.ll, we also met such situation.

We indeed see some codegen cases are worse when disabling perfect shuffle, so they'll be fixed in a more careful way in future patches.

Diff Detail

Event Timeline

qiucf created this revision.Mar 6 2022, 7:14 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 6 2022, 7:14 PM
qiucf requested review of this revision.Mar 6 2022, 7:14 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 6 2022, 7:14 PM
qiucf updated this revision to Diff 414618.Mar 11 2022, 2:05 AM

Update test case

jsji added a comment.Mar 11 2022, 6:43 AM

Can you please add some comments about why it is bad for vector loops? And some general description about the performance test results with this turned off?

qiucf edited the summary of this revision. (Show Details)Mar 13 2022, 7:32 PM
jsji accepted this revision as: jsji.Mar 13 2022, 8:00 PM

Please also mention the attempt to avoid perfect shuffle when mask has multiple uses in https://reviews.llvm.org/D116801.

And also add TODO to testcases that will be handled in future patches.

This revision is now accepted and ready to land.Mar 13 2022, 8:00 PM
This revision was landed with ongoing or failed builds.Mar 15 2022, 1:02 AM
This revision was automatically updated to reflect the committed changes.