This is an archive of the discontinued LLVM Phabricator instance.

[RISCV][SelectionDAG] Introduce an ISD::SPLAT_VECTOR_PARTS node that can represent a splat of 2 i32 values into a nxvXi64 vector for riscv32.
ClosedPublic

Authored by craig.topper on Mar 4 2021, 8:06 PM.

Details

Summary

On riscv32, i64 isn't a legal scalar type but we would like to
support scalable vectors of i64.

This patch introduces a new node that can represent a splat made
of multiple scalar values. I've used this new node to solve the current
crashes we experience when getConstant is used after type legalization.

For RISCV, we are now default expanding SPLAT_VECTOR to SPLAT_VECTOR_PARTS
when needed and then handling the SPLAT_VECTOR_PARTS later during
LegalizeOps. I've remove the special case I previously put in for
ABS for D97991 as the default expansion is now able to succesfully
use getConstant.

Diff Detail

Event Timeline

craig.topper created this revision.Mar 4 2021, 8:06 PM
craig.topper requested review of this revision.Mar 4 2021, 8:06 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 4 2021, 8:07 PM
Herald added a subscriber: MaskRay. · View Herald Transcript
frasercrmck added inline comments.Mar 8 2021, 1:53 AM
llvm/include/llvm/CodeGen/ISDOpcodes.h
574

Do we need to considering opening this up to allow more than two parts from the get-go? We don't really have anything to test it with but I fear it'll be hard to update baked-in assumptions when someone needs a splat_vector_parts with 4 or more parts.

Also, this looks like it should be SPLAT_VECTOR_PARTS(Lo, Hi) as that's how it's used below.

Allow more than 2 scalar parts. Untested and lacking type legalizer support past the conversion from SPLAT_VECTOR to SPLAT_VECTOR_PARTS.

frasercrmck added inline comments.Mar 9 2021, 1:45 AM
llvm/include/llvm/CodeGen/ISDOpcodes.h
574

Last thing I'd question is whether it needs to be explicit which of SCALAR1 and SCALARN are most/least significant. And whether endianness needs to be taken into account?

craig.topper edited the summary of this revision. (Show Details)Mar 9 2021, 10:05 AM
craig.topper edited the summary of this revision. (Show Details)

Clarify scalar order. Mention that endianness doesn't matter.

frasercrmck accepted this revision.Mar 10 2021, 1:13 AM

Thanks, Craig. LGTM!

This revision is now accepted and ready to land.Mar 10 2021, 1:13 AM
This revision was landed with ongoing or failed builds.Mar 10 2021, 9:54 AM
This revision was automatically updated to reflect the committed changes.