Skip to content
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions llvm/lib/Target/RISCV/RISCVISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16191,10 +16191,6 @@ combineVectorSizedSetCCEquality(EVT VT, SDValue X, SDValue Y, ISD::CondCode CC,
return SDValue();

unsigned OpSize = OpVT.getSizeInBits();
// TODO: Support non-power-of-2 types.
if (!isPowerOf2_32(OpSize))
return SDValue();

// The size should be larger than XLen and smaller than the maximum vector
// size.
if (OpSize <= Subtarget.getXLen() ||
Expand All @@ -16215,14 +16211,22 @@ combineVectorSizedSetCCEquality(EVT VT, SDValue X, SDValue Y, ISD::CondCode CC,
Attribute::NoImplicitFloat))
return SDValue();

assert(OpSize % 8 == 0 && "The size should be a multiple of 8");
unsigned VecSize = OpSize / 8;
EVT VecVT = MVT::getVectorVT(MVT::i8, VecSize);
EVT CmpVT = MVT::getVectorVT(MVT::i1, VecSize);
EVT VecVT = EVT::getVectorVT(*DAG.getContext(), MVT::i8, VecSize);
EVT CmpVT = EVT::getVectorVT(*DAG.getContext(), MVT::i1, VecSize);

SDValue VecX = DAG.getBitcast(VecVT, X);
SDValue VecY = DAG.getBitcast(VecVT, Y);
SDValue Cmp = DAG.getSetCC(DL, CmpVT, VecX, VecY, ISD::SETNE);
return DAG.getSetCC(DL, VT, DAG.getNode(ISD::VECREDUCE_OR, DL, XLenVT, Cmp),
SDValue Mask = DAG.getAllOnesConstant(DL, CmpVT);
SDValue VL = DAG.getConstant(VecSize, DL, XLenVT);

SDValue Cmp = DAG.getNode(ISD::VP_SETCC, DL, CmpVT, VecX, VecY,
DAG.getCondCode(ISD::SETNE), Mask, VL);
return DAG.getSetCC(DL, VT,
DAG.getNode(ISD::VP_REDUCE_OR, DL, XLenVT,
DAG.getConstant(0, DL, XLenVT), Cmp, Mask,
VL),
DAG.getConstant(0, DL, XLenVT), CC);
}

Expand Down
21 changes: 7 additions & 14 deletions llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2994,20 +2994,13 @@ RISCVTTIImpl::enableMemCmpExpansion(bool OptSize, bool IsZeroCmp) const {
}

if (IsZeroCmp && ST->hasVInstructions()) {
unsigned RealMinVLen = ST->getRealMinVLen();
// Support Fractional LMULs if the lengths are larger than XLen.
// TODO: Support non-power-of-2 types.
for (unsigned FLMUL = 8; FLMUL >= 2; FLMUL /= 2) {
unsigned Len = RealMinVLen / FLMUL;
if (Len > ST->getXLen())
Options.LoadSizes.insert(Options.LoadSizes.begin(), Len / 8);
}
for (unsigned LMUL = 1; LMUL <= ST->getMaxLMULForFixedLengthVectors();
LMUL *= 2) {
unsigned Len = RealMinVLen * LMUL;
if (Len > ST->getXLen())
Options.LoadSizes.insert(Options.LoadSizes.begin(), Len / 8);
}
unsigned VLenB = ST->getRealMinVLen() / 8;
// The minimum size should be `XLen / 8 + 1`, and the maxinum size should be
// `VLenB * MaxLMUL` so that it fits in a single register group.
unsigned MinSize = ST->getXLen() / 8 + 1;
unsigned MaxSize = VLenB * ST->getMaxLMULForFixedLengthVectors();
for (unsigned Size = MinSize; Size <= MaxSize; Size++)
Options.LoadSizes.insert(Options.LoadSizes.begin(), Size);
}
return Options;
}
Loading