This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Support extract_vector_elt for fixed and scalable masked registers.
ClosedPublic

Authored by craig.topper on Mar 9 2021, 7:50 PM.

Details

Summary

This uses a really simple approach of converting to an i8 vector
and extracting. This is probably not the best approach especially
if you know the index is constant.

Other ideas:
-Store to stack temporary using vse1, load as scalar and shift.
-Sort of bitcast the vector to a vector of i8, slide down the
appropriate 8 bit element, copy to scalar, shift down the
correct bit within the 8 bits we extracted. Not exactly sure
how to describe such a bitcast from i1 vector to i8 vector
within the type system for elements less than 8.

Diff Detail

Event Timeline

craig.topper created this revision.Mar 9 2021, 7:50 PM
craig.topper requested review of this revision.Mar 9 2021, 7:50 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 9 2021, 7:50 PM
Herald added a subscriber: MaskRay. · View Herald Transcript

Does this need to be limited to fixed-length vectors? We're currently unable to do this on scalable vectors too.

As you say, I suspect for vectors of (vscale x) 8/16/32/64/etc x i1 we 'd be better bitcasting to i8, extract an element and shift down any remaining bits. Not sure what's best for 2/4. Insert into a larger vector and do the same process? Same problem as for subvectors, really. A set of mask-vector slide instructions would be great.

-Support scalable vector.
-Add tests.

craig.topper retitled this revision from [RISCV] WIP Support extract_vector_elt for fixed masked registers. to [RISCV] Support extract_vector_elt for fixed and scalable masked registers..Mar 10 2021, 11:17 AM
craig.topper edited the summary of this revision. (Show Details)
This revision is now accepted and ready to land.Mar 11 2021, 1:18 AM