Skip to content

Commit df1194a

Browse files
committed
Revert "[RISCV] Support non-power-of-2 types when expanding memcmp"
This reverts commit ca29c63.
1 parent cdba6bd commit df1194a

File tree

5 files changed

+976
-709
lines changed

5 files changed

+976
-709
lines changed

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16190,6 +16190,10 @@ combineVectorSizedSetCCEquality(EVT VT, SDValue X, SDValue Y, ISD::CondCode CC,
1619016190
return SDValue();
1619116191

1619216192
unsigned OpSize = OpVT.getSizeInBits();
16193+
// TODO: Support non-power-of-2 types.
16194+
if (!isPowerOf2_32(OpSize))
16195+
return SDValue();
16196+
1619316197
// The size should be larger than XLen and smaller than the maximum vector
1619416198
// size.
1619516199
if (OpSize <= Subtarget.getXLen() ||
@@ -16210,25 +16214,14 @@ combineVectorSizedSetCCEquality(EVT VT, SDValue X, SDValue Y, ISD::CondCode CC,
1621016214
Attribute::NoImplicitFloat))
1621116215
return SDValue();
1621216216

16213-
// Bail out for non-byte-sized types.
16214-
if (!OpVT.isByteSized())
16215-
return SDValue();
16216-
1621716217
unsigned VecSize = OpSize / 8;
16218-
EVT VecVT = EVT::getVectorVT(*DAG.getContext(), MVT::i8, VecSize);
16219-
EVT CmpVT = EVT::getVectorVT(*DAG.getContext(), MVT::i1, VecSize);
16218+
EVT VecVT = MVT::getVectorVT(MVT::i8, VecSize);
16219+
EVT CmpVT = MVT::getVectorVT(MVT::i1, VecSize);
1622016220

1622116221
SDValue VecX = DAG.getBitcast(VecVT, X);
1622216222
SDValue VecY = DAG.getBitcast(VecVT, Y);
16223-
SDValue Mask = DAG.getAllOnesConstant(DL, CmpVT);
16224-
SDValue VL = DAG.getConstant(VecSize, DL, XLenVT);
16225-
16226-
SDValue Cmp = DAG.getNode(ISD::VP_SETCC, DL, CmpVT, VecX, VecY,
16227-
DAG.getCondCode(ISD::SETNE), Mask, VL);
16228-
return DAG.getSetCC(DL, VT,
16229-
DAG.getNode(ISD::VP_REDUCE_OR, DL, XLenVT,
16230-
DAG.getConstant(0, DL, XLenVT), Cmp, Mask,
16231-
VL),
16223+
SDValue Cmp = DAG.getSetCC(DL, CmpVT, VecX, VecY, ISD::SETNE);
16224+
return DAG.getSetCC(DL, VT, DAG.getNode(ISD::VECREDUCE_OR, DL, XLenVT, Cmp),
1623216225
DAG.getConstant(0, DL, XLenVT), CC);
1623316226
}
1623416227

llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2985,13 +2985,20 @@ RISCVTTIImpl::enableMemCmpExpansion(bool OptSize, bool IsZeroCmp) const {
29852985
}
29862986

29872987
if (IsZeroCmp && ST->hasVInstructions()) {
2988-
unsigned VLenB = ST->getRealMinVLen() / 8;
2989-
// The minimum size should be `XLen / 8 + 1`, and the maxinum size should be
2990-
// `VLenB * MaxLMUL` so that it fits in a single register group.
2991-
unsigned MinSize = ST->getXLen() / 8 + 1;
2992-
unsigned MaxSize = VLenB * ST->getMaxLMULForFixedLengthVectors();
2993-
for (unsigned Size = MinSize; Size <= MaxSize; Size++)
2994-
Options.LoadSizes.insert(Options.LoadSizes.begin(), Size);
2988+
unsigned RealMinVLen = ST->getRealMinVLen();
2989+
// Support Fractional LMULs if the lengths are larger than XLen.
2990+
// TODO: Support non-power-of-2 types.
2991+
for (unsigned FLMUL = 8; FLMUL >= 2; FLMUL /= 2) {
2992+
unsigned Len = RealMinVLen / FLMUL;
2993+
if (Len > ST->getXLen())
2994+
Options.LoadSizes.insert(Options.LoadSizes.begin(), Len / 8);
2995+
}
2996+
for (unsigned LMUL = 1; LMUL <= ST->getMaxLMULForFixedLengthVectors();
2997+
LMUL *= 2) {
2998+
unsigned Len = RealMinVLen * LMUL;
2999+
if (Len > ST->getXLen())
3000+
Options.LoadSizes.insert(Options.LoadSizes.begin(), Len / 8);
3001+
}
29953002
}
29963003
return Options;
29973004
}

llvm/test/CodeGen/RISCV/icmp-non-byte-sized.ll

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)