This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Expand scalable vector bswap. Fix crash for bitreverse.
ClosedPublic

Authored by craig.topper on Oct 21 2021, 10:10 AM.

Details

Summary

Fix LegalizeVectorOps to not try shuffle or unrolling expansions for
scalable vectors.

Diff Detail

Event Timeline

craig.topper created this revision.Oct 21 2021, 10:10 AM
craig.topper requested review of this revision.Oct 21 2021, 10:10 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 21 2021, 10:10 AM
Herald added a subscriber: MaskRay. · View Herald Transcript

It's not very clear to me why we have different ways of expanding bswap. Why doesn't VectorLegalizer::ExpandBSWAP always call TLI.expandBSWAP, for instance?

It's not very clear to me why we have different ways of expanding bswap. Why doesn't VectorLegalizer::ExpandBSWAP always call TLI.expandBSWAP, for instance?

ExpandBSWAP is using the shift+and+or expansion. VectorLegalizer::ExpandBSWAP tries to use a shuffle+bitcast which would only be legal for a vector. I suppose we could sink that into expandBSWAP with a .isFixedVector() check if that's what you're asking?

llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp
1099

I've made a bold assumption here that SHL/SRL/AND/OR are all LegalOrCustom for a scalable vector. Otherwise the unroll fallback would crash.

RKSimon accepted this revision.Oct 31 2021, 8:16 AM

LGTM

This revision is now accepted and ready to land.Oct 31 2021, 8:16 AM