This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC] emit VSX instructions instead of VMX instructions for vector loads and stores
ClosedPublic

Authored by quinnp on Jun 8 2022, 7:56 AM.

Details

Summary

This patch changes the PowerPC backend to generate VSX load/store instructions
for all vector loads/stores on Power8 and earlier (LE) instead of VMX
load/store instructions. The reason for this change is because VMX instructions
require the vector to be 16-byte aligned. So, a vector load/store will fail with
VMX instructions if the vector is misaligned. Also, gcc generates VSX
instructions in this situation which allow for unaligned access but require a
swap instruction after loading/before storing. This is not an issue for BE
because we already emit VSX instructions since no swap is required. And this is
not an issue on Power9 and up since we have access to lxv[x]/stxv[x] which
allow for unaligned access and do not require swaps.

This patch also delays the VSX load/store for LE combines until after
LegalizeOps to prioritize other load/store combines.

Diff Detail

Event Timeline

quinnp created this revision.Jun 8 2022, 7:56 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 8 2022, 7:56 AM
quinnp requested review of this revision.Jun 8 2022, 7:56 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 8 2022, 7:57 AM
quinnp added reviewers: nemanjai, lei, Restricted Project.Jun 8 2022, 7:58 AM
quinnp updated this revision to Diff 435961.Jun 10 2022, 10:11 AM

Rebasing with main.

quinnp edited the summary of this revision. (Show Details)Jun 13 2022, 11:55 AM
quinnp edited the summary of this revision. (Show Details)Jun 13 2022, 11:57 AM
quinnp updated this revision to Diff 437131.Jun 15 2022, 6:21 AM

Updating patch to delay SVX load and store combine until after legalization.

quinnp updated this revision to Diff 437149.Jun 15 2022, 7:12 AM

Adding a comments to the early exits in expandVSXLoadForLE and expandVSXStoreForLE.

quinnp edited the summary of this revision. (Show Details)Jun 15 2022, 7:13 AM
quinnp added a reviewer: stefanp.
stefanp accepted this revision.Jun 15 2022, 9:24 AM

LGTM

This revision is now accepted and ready to land.Jun 15 2022, 9:24 AM
This revision was landed with ongoing or failed builds.Jun 15 2022, 10:06 AM
This revision was automatically updated to reflect the committed changes.