This is an archive of the discontinued LLVM Phabricator instance.

[mips][msa] Fix generation of bm(n)zi and bins[lr]i instructions
ClosedPublic

Authored by smaksimovic on Mar 3 2017, 8:37 AM.

Details

Summary

[mips][msa] Fix generation of bm(n)zi and bins[lr]i instructions

We have two cases here, the first one being the following instruction selection from the builtin function:
bm(n)zi builtin -> vselect node -> bins[lr]i machine instruction

In case of bm(n)zi having an immediate which has either its high or low bits set, a bins[lr] instruction can be selected through the selectVSplatMask[LR] function.
The function counts the number of bits set, and that value is being passed to the bins[lr]i instruction as its immediate, which in turn copies immediate modulo
the size of the element in bits plus 1 as per specs, where we get the off-by-one-error.

The other case is:
bins[lr]i -> vselect node -> bsel.v

In this case, a bsel.v instruction gets selected with a mask having one bit less set than required.

Diff Detail

Repository
rL LLVM

Event Timeline

smaksimovic created this revision.Mar 3 2017, 8:37 AM
sdardis accepted this revision.Apr 4 2017, 8:46 AM

Some comments inlined. rL297457 lifted the restriction on splat values being restricted to signed 10 bit values.

LGTM.

test/CodeGen/Mips/msa/bmzi_bmnzi.ll
19 ↗(On Diff #90492)

This should be CHECK-LABEL:

42 ↗(On Diff #90492)

This should be CHECK-LABEL:

test/CodeGen/Mips/msa/i5-b.ll
117 ↗(On Diff #90492)

Unnecessary change. For the bins[lr]i.[hwd] cases, you don't need to modify the test cases. The .b cases need to be changed as otherwise the entire element gets selected and this gets optimized out.

test/CodeGen/Mips/msa/immediates.ll
619 ↗(On Diff #90492)

This appears to the only line that requires changing in this test. The others are unnecessary.

This revision is now accepted and ready to land.Apr 4 2017, 8:46 AM
smaksimovic updated this revision to Diff 94502.Apr 7 2017, 3:16 AM

Made changes as per review comments.

smaksimovic edited the summary of this revision. (Show Details)Apr 7 2017, 4:33 AM
smaksimovic retitled this revision from [mips][msa] Fix generation of bmn?zi and bins[lr]i instructions to [mips][msa] Fix generation of bm(n)zi and bins[lr]i instructions.Apr 7 2017, 6:36 AM
smaksimovic edited the summary of this revision. (Show Details)
This revision was automatically updated to reflect the committed changes.