@@ -16172,80 +16172,17 @@ static bool narrowIndex(SDValue &N, ISD::MemIndexType IndexType, SelectionDAG &D
16172
16172
return true;
16173
16173
}
16174
16174
16175
- /// Try to map an integer comparison with size > XLEN to vector instructions
16176
- /// before type legalization splits it up into chunks.
16177
- static SDValue
16178
- combineVectorSizedSetCCEquality(EVT VT, SDValue X, SDValue Y, ISD::CondCode CC,
16179
- const SDLoc &DL, SelectionDAG &DAG,
16180
- const RISCVSubtarget &Subtarget) {
16181
- assert(ISD::isIntEqualitySetCC(CC) && "Bad comparison predicate");
16182
-
16183
- if (!Subtarget.hasVInstructions())
16184
- return SDValue();
16185
-
16186
- MVT XLenVT = Subtarget.getXLenVT();
16187
- EVT OpVT = X.getValueType();
16188
- // We're looking for an oversized integer equality comparison.
16189
- if (!OpVT.isScalarInteger())
16190
- return SDValue();
16191
-
16192
- unsigned OpSize = OpVT.getSizeInBits();
16193
- // TODO: Support non-power-of-2 types.
16194
- if (!isPowerOf2_32(OpSize))
16195
- return SDValue();
16196
-
16197
- // The size should be larger than XLen and smaller than the maximum vector
16198
- // size.
16199
- if (OpSize <= Subtarget.getXLen() ||
16200
- OpSize > Subtarget.getRealMinVLen() *
16201
- Subtarget.getMaxLMULForFixedLengthVectors())
16202
- return SDValue();
16203
-
16204
- // Don't perform this combine if constructing the vector will be expensive.
16205
- auto IsVectorBitCastCheap = [](SDValue X) {
16206
- X = peekThroughBitcasts(X);
16207
- return isa<ConstantSDNode>(X) || X.getValueType().isVector() ||
16208
- X.getOpcode() == ISD::LOAD;
16209
- };
16210
- if (!IsVectorBitCastCheap(X) || !IsVectorBitCastCheap(Y))
16211
- return SDValue();
16212
-
16213
- if (DAG.getMachineFunction().getFunction().hasFnAttribute(
16214
- Attribute::NoImplicitFloat))
16215
- return SDValue();
16216
-
16217
- unsigned VecSize = OpSize / 8;
16218
- EVT VecVT = MVT::getVectorVT(MVT::i8, VecSize);
16219
- EVT CmpVT = MVT::getVectorVT(MVT::i1, VecSize);
16220
-
16221
- SDValue VecX = DAG.getBitcast(VecVT, X);
16222
- SDValue VecY = DAG.getBitcast(VecVT, Y);
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),
16225
- DAG.getConstant(0, DL, XLenVT), CC);
16226
- }
16227
-
16228
16175
// Replace (seteq (i64 (and X, 0xffffffff)), C1) with
16229
16176
// (seteq (i64 (sext_inreg (X, i32)), C1')) where C1' is C1 sign extended from
16230
16177
// bit 31. Same for setne. C1' may be cheaper to materialize and the sext_inreg
16231
16178
// can become a sext.w instead of a shift pair.
16232
16179
static SDValue performSETCCCombine(SDNode *N, SelectionDAG &DAG,
16233
16180
const RISCVSubtarget &Subtarget) {
16234
- SDLoc dl(N);
16235
16181
SDValue N0 = N->getOperand(0);
16236
16182
SDValue N1 = N->getOperand(1);
16237
16183
EVT VT = N->getValueType(0);
16238
16184
EVT OpVT = N0.getValueType();
16239
16185
16240
- ISD::CondCode Cond = cast<CondCodeSDNode>(N->getOperand(2))->get();
16241
- // Looking for an equality compare.
16242
- if (!isIntEqualitySetCC(Cond))
16243
- return SDValue();
16244
-
16245
- if (SDValue V =
16246
- combineVectorSizedSetCCEquality(VT, N0, N1, Cond, dl, DAG, Subtarget))
16247
- return V;
16248
-
16249
16186
if (OpVT != MVT::i64 || !Subtarget.is64Bit())
16250
16187
return SDValue();
16251
16188
@@ -16260,6 +16197,11 @@ static SDValue performSETCCCombine(SDNode *N, SelectionDAG &DAG,
16260
16197
N0.getConstantOperandVal(1) != UINT64_C(0xffffffff))
16261
16198
return SDValue();
16262
16199
16200
+ // Looking for an equality compare.
16201
+ ISD::CondCode Cond = cast<CondCodeSDNode>(N->getOperand(2))->get();
16202
+ if (!isIntEqualitySetCC(Cond))
16203
+ return SDValue();
16204
+
16263
16205
// Don't do this if the sign bit is provably zero, it will be turned back into
16264
16206
// an AND.
16265
16207
APInt SignMask = APInt::getOneBitSet(64, 31);
@@ -16268,6 +16210,7 @@ static SDValue performSETCCCombine(SDNode *N, SelectionDAG &DAG,
16268
16210
16269
16211
const APInt &C1 = N1C->getAPIntValue();
16270
16212
16213
+ SDLoc dl(N);
16271
16214
// If the constant is larger than 2^32 - 1 it is impossible for both sides
16272
16215
// to be equal.
16273
16216
if (C1.getActiveBits() > 32)
0 commit comments