Skip to content

Commit 94aadc8

Browse files
committed
[RISCV] Disable combineToVCPOP for illegal scalable vector types.
This transform creates target specific instructions which must have legal types. We were checking this for fixed vectors, but not scalable vectors. This caused a crash with <vscale x 1 x i1> which isn't legal for Zve32x.
1 parent d71b6cf commit 94aadc8

File tree

2 files changed

+726
-3
lines changed

2 files changed

+726
-3
lines changed

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18798,6 +18798,10 @@ static SDValue combineToVCPOP(SDNode *N, SelectionDAG &DAG,
1879818798
if (!SrcMVT.isVector() || SrcMVT.getVectorElementType() != MVT::i1)
1879918799
return SDValue();
1880018800

18801+
const TargetLowering &TLI = DAG.getTargetLoweringInfo();
18802+
if (!TLI.isTypeLegal(SrcMVT))
18803+
return SDValue();
18804+
1880118805
// Check that destination type is large enough to hold result without
1880218806
// overflow.
1880318807
if (Opc == ISD::VECREDUCE_ADD) {
@@ -18814,9 +18818,6 @@ static SDValue combineToVCPOP(SDNode *N, SelectionDAG &DAG,
1881418818

1881518819
MVT ContainerVT = SrcMVT;
1881618820
if (SrcMVT.isFixedLengthVector()) {
18817-
if (!useRVVForFixedLengthVectorVT(SrcMVT, Subtarget))
18818-
return SDValue();
18819-
1882018821
ContainerVT = getContainerForFixedLengthVector(DAG, SrcMVT, Subtarget);
1882118822
Src = convertToScalableVector(ContainerVT, Src, DAG, Subtarget);
1882218823
}

0 commit comments

Comments
 (0)