This is an archive of the discontinued LLVM Phabricator instance.

[X86] Add support for turning vXi1 shuffles into KSHIFTL/KSHIFTR.
ClosedPublic

Authored by craig.topper on Aug 28 2018, 11:53 PM.

Details

Summary

This patch recognizes shuffles that shift elements and fill with zeros. I've copied and modified the shift matching code we use for normal vector registers to do this. I'm not sure if there's a good way to share more of this code without making the existing function more complex than it already is.

This will be used to enable kshift intrinsics in clang.

Diff Detail

Repository
rL LLVM

Event Timeline

craig.topper created this revision.Aug 28 2018, 11:53 PM
craig.topper edited the summary of this revision. (Show Details)

Add test cases for KNL and SKX. The KNL code is pretty terrible on anything but v16i1, but that's to be expected since we don't have the v32i1 or v64i1 types on KNL or an 8-bit kshift. The intrinsics that will be added for clang will only use 8, 32, and 64 on cpus with avx512dq/avx512bw so this isn't an issue that needs to be addressed immediately.

RKSimon added inline comments.Aug 30 2018, 8:35 AM
lib/Target/X86/X86ISelLowering.cpp
15061 ↗(On Diff #163197)

I guess merging this with matchVectorShuffleAsShift just messes everything up?

15075 ↗(On Diff #163197)

return isSequentialOrUndefInRange(Mask, Pos, Len, Low + MaskOffset);

15143 ↗(On Diff #163197)

Merge these two cases into a for loop?

Address review comments. Rebase after pre-committing new tests.

RKSimon accepted this revision.Aug 31 2018, 2:28 AM

LGTM

This revision is now accepted and ready to land.Aug 31 2018, 2:28 AM
This revision was automatically updated to reflect the committed changes.