@@ -20370,7 +20370,7 @@ static bool hasPairwiseAdd(unsigned Opcode, EVT VT, bool FullFP16) {
20370
20370
}
20371
20371
20372
20372
static SDValue getPTest(SelectionDAG &DAG, EVT VT, SDValue Pg, SDValue Op,
20373
- AArch64CC::CondCode Cond, bool EmitCSel = true );
20373
+ AArch64CC::CondCode Cond);
20374
20374
20375
20375
static bool isPredicateCCSettingOp(SDValue N) {
20376
20376
if ((N.getOpcode() == ISD::SETCC) ||
@@ -20495,7 +20495,6 @@ static SDValue
20495
20495
performExtractVectorEltCombine(SDNode *N, TargetLowering::DAGCombinerInfo &DCI,
20496
20496
const AArch64Subtarget *Subtarget) {
20497
20497
assert(N->getOpcode() == ISD::EXTRACT_VECTOR_ELT);
20498
-
20499
20498
if (SDValue Res = performFirstTrueTestVectorCombine(N, DCI, Subtarget))
20500
20499
return Res;
20501
20500
if (SDValue Res = performLastTrueTestVectorCombine(N, DCI, Subtarget))
@@ -22536,7 +22535,7 @@ static SDValue tryConvertSVEWideCompare(SDNode *N, ISD::CondCode CC,
22536
22535
}
22537
22536
22538
22537
static SDValue getPTest(SelectionDAG &DAG, EVT VT, SDValue Pg, SDValue Op,
22539
- AArch64CC::CondCode Cond, bool EmitCSel ) {
22538
+ AArch64CC::CondCode Cond) {
22540
22539
const TargetLowering &TLI = DAG.getTargetLoweringInfo();
22541
22540
22542
22541
SDLoc DL(Op);
@@ -22569,8 +22568,6 @@ static SDValue getPTest(SelectionDAG &DAG, EVT VT, SDValue Pg, SDValue Op,
22569
22568
22570
22569
// Set condition code (CC) flags.
22571
22570
SDValue Test = DAG.getNode(PTest, DL, MVT::i32, Pg, Op);
22572
- if (!EmitCSel)
22573
- return Test;
22574
22571
22575
22572
// Convert CC to integer based on requested condition.
22576
22573
// NOTE: Cond is inverted to promote CSEL's removal when it feeds a compare.
@@ -27237,6 +27234,21 @@ static bool isLanes1toNKnownZero(SDValue Op) {
27237
27234
}
27238
27235
}
27239
27236
27237
+ // Return true if the vector operation can guarantee that the first lane of its
27238
+ // result is active.
27239
+ static bool isLane1KnownActive(SDValue Op) {
27240
+ switch (Op.getOpcode()) {
27241
+ default:
27242
+ return false;
27243
+ case AArch64ISD::REINTERPRET_CAST:
27244
+ return isLane1KnownActive(Op->getOperand(0));
27245
+ case ISD::SPLAT_VECTOR:
27246
+ return isOneConstant(Op.getOperand(0));
27247
+ case AArch64ISD::PTRUE:
27248
+ return Op.getConstantOperandVal(0) == AArch64SVEPredPattern::all;
27249
+ };
27250
+ }
27251
+
27240
27252
static SDValue removeRedundantInsertVectorElt(SDNode *N) {
27241
27253
assert(N->getOpcode() == ISD::INSERT_VECTOR_ELT && "Unexpected node!");
27242
27254
SDValue InsertVec = N->getOperand(0);
@@ -27532,22 +27544,17 @@ static SDValue performPTestFirstCombine(SDNode *N,
27532
27544
auto Mask = N->getOperand(0);
27533
27545
auto Pred = N->getOperand(1);
27534
27546
27535
- if (Mask->getOpcode() == AArch64ISD::REINTERPRET_CAST)
27536
- Mask = Mask->getOperand(0);
27537
-
27538
27547
if (Pred->getOpcode() == AArch64ISD::REINTERPRET_CAST)
27539
27548
Pred = Pred->getOperand(0);
27540
27549
27541
- if (Pred->getValueType(0).getVectorElementType() != MVT::i1 ||
27542
- !isAllActivePredicate(DAG, Mask))
27550
+ if (!isLane1KnownActive(Mask))
27543
27551
return SDValue();
27544
27552
27545
27553
if (Pred->getOpcode() == ISD::CONCAT_VECTORS) {
27546
27554
Pred = Pred->getOperand(0);
27547
- SDValue Mask = DAG.getSplatVector(Pred->getValueType(0), DL,
27548
- DAG.getAllOnesConstant(DL, MVT::i64));
27549
- return getPTest(DAG, N->getValueType(0), Mask, Pred,
27550
- AArch64CC::FIRST_ACTIVE, /* EmitCSel */ false);
27555
+ Pred = DAG.getNode(AArch64ISD::REINTERPRET_CAST, DL, MVT::nxv16i1, Pred);
27556
+ return DAG.getNode(AArch64ISD::PTEST_FIRST, DL, N->getValueType(0), Mask,
27557
+ Pred);
27551
27558
}
27552
27559
27553
27560
return SDValue();
0 commit comments