This is an archive of the discontinued LLVM Phabricator instance.

[mips] Correct and improve special-case shuffle instructions.
ClosedPublic

Authored by dsanders on May 11 2015, 6:56 AM.

Details

Summary

The documentation writes vectors highest-index first whereas LLVM-IR writes
them lowest-index first. As a result, instructions defined in terms of
left_half() and right_half() had the halves reversed.

In addition to correcting them, they have been improved to allow shuffles
that use the same operand twice or in reverse order. For example, ilvev
used to accept masks of the form:

<0, n, 2, n+2, 4, n+4, ...>

but now accepts:

<0, 0, 2, 2, 4, 4, ...>
<n, n, n+2, n+2, n+4, n+4, ...>
<0, n, 2, n+2, 4, n+4, ...>
<n, 0, n+2, 2, n+4, 4, ...>

One further improvement is that splati.[bhwd] is now the preferred instruction
for splat-like operations. The other special shuffles are no longer used
for splats. This lead to the discovery that <0, 0, ...> would not cause
splati.[hwd] to be selected and this has also been fixed.

This fixes the enc-3des test from the test-suite on Mips64r6 with MSA.

Diff Detail

Event Timeline

dsanders updated this revision to Diff 25466.May 11 2015, 6:56 AM
dsanders retitled this revision from to [mips] Correct and improve special-case shuffle instructions..
dsanders updated this object.
dsanders edited the test plan for this revision. (Show Details)
dsanders added a reviewer: vkalintiris.
dsanders added a subscriber: Unknown Object (MLST).
vkalintiris accepted this revision.May 14 2015, 4:21 AM
vkalintiris edited edge metadata.

LGTM with a couple nits/suggestions.

lib/Target/Mips/MipsSEISelLowering.cpp
2468–2469

Did you intend to use 3 slashes instead of 2?

2470–2475
  • Every instantiation of the template is using an int. There's no need for it.
  • Just a personal preference but can we swap the 2nd argument with the 3rd, so that End comes right after Begin?
  • Also, can we document a little bit the role of each argument and find a more descriptive name for ExpectedIndex?
test/CodeGen/Mips/msa/shuffle.ll
4

The 3rd argument is unused in this and some of the following tests. Can we remove it from those function definitions while we're at it?

This revision is now accepted and ready to land.May 14 2015, 4:21 AM
dsanders closed this revision.May 19 2015, 5:28 AM