Page MenuHomePhabricator

[Power9] Add additional patterns to recognize and transform insertelt/extractelt to vinsert[h|b]/vextractu[h|b] instructions.
ClosedPublic

Authored by gyiu on Jun 26 2017, 9:59 AM.

Details

Summary
  • Added code to recognize insertelement on v8i16/v16i8 vectors and transform to use vinserth/vinsertb instructions.
  • Added code to recognize extractelement on v8i16/v16i8 vectors, specifically extracting the elements from doubleword element 1 of a VSR, to use vextractuh/vextractub instructions. The normal code-gen requires an extra xxswapd instruction to get the elements into the proper half of the register before a mfvsrd.
  • Added LIT tests for above patterns.

Diff Detail

Repository
rL LLVM

Event Timeline

gyiu created this revision.Jun 26 2017, 9:59 AM
nemanjai edited edge metadata.Jun 29 2017, 1:09 AM

I think the vector extract portion of this interacts with https://reviews.llvm.org/D34032. We should figure out which of the two sequences is optimal and settle on that.

kbarton requested changes to this revision.Aug 22 2017, 1:36 PM

Did @nemanjai comment about the vector extracts get addressed?

This revision now requires changes to proceed.Aug 22 2017, 1:36 PM
gyiu added a comment.EditedAug 23 2017, 11:32 AM

@nemanjai @kbarton I believe the code sequences that 'https://reviews.llvm.org/D34032' generate have equal or less than the number of cycles these 'vextractu[h|b] + mfvsrd' sequences. Also, they are more general and can handle more cases. Therefore I don't think the extract portion of this patch is useful anymore. However, the insertelement patterns are still good to have IMO.

gyiu updated this revision to Diff 113263.Aug 30 2017, 7:59 AM
gyiu edited edge metadata.
  • Removed extract element patterns as changes from 'https://reviews.llvm.org/D34032' generate better code in terms of total cycles. Also it catches more cases than the vextractu[hb] instructions, as it's only beneficial when operating on dword[1] of the vector register.
kbarton accepted this revision.Oct 23 2017, 8:06 PM

LGTM

This revision is now accepted and ready to land.Oct 23 2017, 8:06 PM
This revision was automatically updated to reflect the committed changes.