This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Fix crash in lowerVECTOR_INTERLEAVE when VecVT is an LMUL=8 type.
ClosedPublic

Authored by craig.topper on Jun 7 2023, 4:37 PM.

Details

Summary

If VecVT is an LMUL=8 VT, we can't concatenate the vectors as that
would create an illegal type. Instead we need to split the vectors
and emit two VECTOR_INTERLEAVE operations that can each be lowered.

Diff Detail

Event Timeline

craig.topper created this revision.Jun 7 2023, 4:37 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 7 2023, 4:37 PM
craig.topper requested review of this revision.Jun 7 2023, 4:37 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 7 2023, 4:37 PM
fakepaper56 added inline comments.Jun 7 2023, 7:03 PM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
7715

Whist is the reason that we don't expand LMUL=8 VECTOR_INTERLEAVE? I think DAGTypeLegalizer::SplitVecRes_VECTOR_DEINTERLEAVE does the same job.

craig.topper added inline comments.Jun 7 2023, 7:13 PM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
7715

The ISD::VECTOR_INTERLEAVE node takes 2 inputs and produces 2 results with the same number of elements. This is different than IR where it's 2 inputs and 1 result with 2 twice as many elements.

The test cases that crash started in IR as interleaving 2 MUL=8 types to produce a LMUL=16 result. In SelectionDAG this is represented as 2 LMUL=8 inputs and 2 LMUL=8 outputs. Type legalization only sees the LMUL=8 types so all the types looks legal.

The RISC-V lowering code concatenates the 2 LMUL=8 values into an LMUL=16 type which crashes because that isn't a legal type.

This patch splits the inputs into LMUL=4 pieces and creates to INTERLEAVE operations. When each of the INTERLEAVE operations is then lowered the concatenation will only produce an LMUL=8 type.

fakepaper56 added inline comments.Jun 7 2023, 8:15 PM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
7715

Thank you. I misunderstood this.

This revision is now accepted and ready to land.Jun 7 2023, 8:20 PM
This revision was landed with ongoing or failed builds.Jun 8 2023, 8:47 AM
This revision was automatically updated to reflect the committed changes.