This is an archive of the discontinued LLVM Phabricator instance.

[x86] lower shuffle of extracts to AVX2 vperm instructions
ClosedPublic

Authored by spatel on Jan 15 2019, 4:09 PM.

Details

Summary

I was trying to prevent shuffle regressions while matching more horizontal ops and ended up here:

shuf (extract X, 0), (extract X, 4), Mask --> extract (shuf X, undef, Mask'), 0

I think the affected tests were added for:
https://bugs.llvm.org/show_bug.cgi?id=34380

This patch won't change the examples in the bug report itself, but we might be able to extend this to catch more types.

Diff Detail

Repository
rL LLVM

Event Timeline

spatel created this revision.Jan 15 2019, 4:09 PM
RKSimon accepted this revision.Jan 16 2019, 1:51 AM

LGTM with a few minors

lib/Target/X86/X86ISelLowering.cpp
11683 ↗(On Diff #181907)

Really these should be safe now, but it might be better to use:

SDValue ExtIdx0 = N0.getOperand(1);
const APInt &ExtIndex0 = cast<ConstantSDNode>(ExtIdx0)->getAPIntValue();

I keep wondering whether we should have made getConstantOperandVal return APInt&

11698 ↗(On Diff #181907)

NewMask.append(NumElts, -1);

test/CodeGen/X86/avx512-shuffles/partial_permute.ll
1052 ↗(On Diff #181907)

This looks like a missed opportunity to merge a avx512 mask select across an extract_subvector(vec,0) ? There a few more below as well, please can you raise a bug about them.

vmovdqa {{.*#+}} ymm2 = <5,3,2,5,u,u,u,u>
vptestnmd %xmm1, %xmm1, %k1
vpermd %ymm0, %ymm2, %ymm0 {%k1} {z}
This revision is now accepted and ready to land.Jan 16 2019, 1:51 AM
spatel marked 4 inline comments as done.Jan 16 2019, 6:03 AM
spatel added inline comments.
test/CodeGen/X86/avx512-shuffles/partial_permute.ll
1052 ↗(On Diff #181907)
This revision was automatically updated to reflect the committed changes.
spatel marked an inline comment as done.