This is an archive of the discontinued LLVM Phabricator instance.

Improving shuffle lowering by using AVX-512 EXPAND* instructions
ClosedPublic

Authored by m_zuckerman on Jan 5 2017, 5:31 AM.

Details

Summary

As described in the bug: https://llvm.org/bugs/show_bug.cgi?id=31351

  1. This patch adds new type of shuffle lowering:
  2. We can use the expand instruction, When the shuffle pattern is as following { 0*a[0]0*a[1]...0*a[n] , n >=0 where a[] elements in a ascending order}.
InstructionCPUID Feature Flag
V(P)EXPAND.* xmm1 {k1}{z},xmm2/m128AVX512VL and AVX512F
V(P)EXPAND.* ymm1 {k1}{z},ymm2/m256AVX512VL and AVX512F
V(P)EXPAND.* zmm1 {k1}{z},zmm2/m512AVX512F

Diff Detail

Repository
rL LLVM

Event Timeline

m_zuckerman updated this revision to Diff 83222.Jan 5 2017, 5:31 AM
m_zuckerman retitled this revision from to Improve shuffle lowering by using AVX-512 EXPAND* instructions.
m_zuckerman updated this object.
m_zuckerman updated this object.
m_zuckerman updated this object.
m_zuckerman retitled this revision from Improve shuffle lowering by using AVX-512 EXPAND* instructions to Improving shuffle lowering by using AVX-512 EXPAND* instructions.Jan 5 2017, 5:34 AM
m_zuckerman updated this object.Jan 5 2017, 5:38 AM
RKSimon edited edge metadata.Jan 5 2017, 6:26 AM

Rename shuffle-to-expand.ll to vector-shuffle-avx512.ll to match existing convention?

lib/Target/X86/X86ISelLowering.cpp
8025 ↗(On Diff #83222)
for (int i = 0, e = Zeroable.size(); i < e; i++) {
8026 ↗(On Diff #83222)
if (Zeroable[i])
  continue;
8104 ↗(On Diff #83222)
for (int i = 0, e = Zeroable.size(); i < e; i++)
8116 ↗(On Diff #83222)

Early out.

if (!isNonZeroElementsInOrder(Zeroable, Mask, V1.getValueType(), IsLeftZeroSide)
  return SDValue();
12732 ↗(On Diff #83222)

const SmallBitVector &Zeroable,

12784 ↗(On Diff #83222)

const SmallBitVector &Zeroable,

test/CodeGen/X86/shuffle-to-expand.ll
1 ↗(On Diff #83222)

This file's CHECK's don't look like it was autogenerated,

m_zuckerman updated this revision to Diff 83435.Jan 6 2017, 2:46 PM
m_zuckerman edited edge metadata.
m_zuckerman marked 6 inline comments as done.
m_zuckerman updated this revision to Diff 83446.Jan 6 2017, 3:39 PM
m_zuckerman added inline comments.Jan 6 2017, 3:44 PM
test/CodeGen/X86/vector-shuffle-avx512.ll
1 ↗(On Diff #83446)

This file was created by update_llc_test_checks.py. I did only a small modifications on it , like delete un-relevant lines. If you prefer , I can put the all output without modifications.

craig.topper added inline comments.Jan 6 2017, 10:27 PM
lib/Target/X86/X86ISelLowering.cpp
8103 ↗(On Diff #83446)

function is misspelled

8104 ↗(On Diff #83446)

argument*

8127 ↗(On Diff #83446)

We generally use something shorter like NumElts. But at least should start with a capital letter.

8132 ↗(On Diff #83446)

Use MVT::getVectorVT which is a static method. Don't rely on VT to get to it.

12407 ↗(On Diff #83446)

EXPAND*

12732 ↗(On Diff #83222)

I think Simon was asking for pass by reference for consistency with the rest of the shuffle lowering code.

Though SmallBitVector is small enough it could probably be passed by value. But consistency wins out.

test/CodeGen/X86/vector-shuffle-avx512.ll
1 ↗(On Diff #83446)

We generally prefer all the lines to be there so the next person who makes a change can re-generate the test without having to duplicate any modifications.

m_zuckerman updated this object.Jan 7 2017, 9:58 AM
m_zuckerman updated this object.
m_zuckerman updated this object.
m_zuckerman updated this object.
m_zuckerman updated this object.Jan 7 2017, 10:04 AM
m_zuckerman updated this object.Jan 7 2017, 10:07 AM
m_zuckerman marked 5 inline comments as done.
m_zuckerman marked 2 inline comments as done.Jan 7 2017, 1:45 PM
RKSimon accepted this revision.Jan 9 2017, 2:57 PM
RKSimon edited edge metadata.

LGTM

This revision is now accepted and ready to land.Jan 9 2017, 2:57 PM
This revision was automatically updated to reflect the committed changes.