[RISCV] Fix crash when legalizing mgather/scatter on rv32

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.
This commit is contained in:
Philip Reames 2023-09-18 08:06:04 -07:00 committed by Philip Reames
parent 38c59b9f53
commit 13a74d6cc8

View File

@ -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 =
@ -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 =