Skip to content

Commit

Permalink
[RISCV] Fix crash when legalizing mgather/scatter on rv32
Browse files Browse the repository at this point in the history
This is a fix for a subset of legalization problems around 64 bit indices on
rv32 targets.  For RV32+V, we were using the wrong mask type for the manual
truncation lowering for fixed length vectors.  Instead, just use the generic
TRUNCATE node, and let it be lowered as needed.

Note that legalization is still broken for rv32+zve32.  That appears to be
a different issue.
  • Loading branch information
preames committed Sep 18, 2023
1 parent 38c59b9 commit 13a74d6
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions llvm/lib/Target/RISCV/RISCVISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10116,10 +10116,7 @@ SDValue RISCVTargetLowering::lowerMaskedGather(SDValue Op,

if (XLenVT == MVT::i32 && IndexVT.getVectorElementType().bitsGT(XLenVT)) {
IndexVT = IndexVT.changeVectorElementType(XLenVT);
SDValue TrueMask = DAG.getNode(RISCVISD::VMSET_VL, DL, Mask.getValueType(),
VL);
Index = DAG.getNode(RISCVISD::TRUNCATE_VECTOR_VL, DL, IndexVT, Index,
TrueMask, VL);
Index = DAG.getNode(ISD::TRUNCATE, DL, IndexVT, Index);
}

unsigned IntID =
Expand Down Expand Up @@ -10218,10 +10215,7 @@ SDValue RISCVTargetLowering::lowerMaskedScatter(SDValue Op,

if (XLenVT == MVT::i32 && IndexVT.getVectorElementType().bitsGT(XLenVT)) {
IndexVT = IndexVT.changeVectorElementType(XLenVT);
SDValue TrueMask = DAG.getNode(RISCVISD::VMSET_VL, DL, Mask.getValueType(),
VL);
Index = DAG.getNode(RISCVISD::TRUNCATE_VECTOR_VL, DL, IndexVT, Index,
TrueMask, VL);
Index = DAG.getNode(ISD::TRUNCATE, DL, IndexVT, Index);
}

unsigned IntID =
Expand Down

0 comments on commit 13a74d6

Please sign in to comment.