@@ -296,7 +296,6 @@ void RISCVDAGToDAGISel::addVectorLoadStoreOperands(
296
296
bool IsMasked, bool IsStridedOrIndexed, SmallVectorImpl<SDValue> &Operands,
297
297
bool IsLoad, MVT *IndexVT) {
298
298
SDValue Chain = Node->getOperand (0 );
299
- SDValue Glue;
300
299
301
300
Operands.push_back (Node->getOperand (CurOp++)); // Base pointer.
302
301
@@ -307,11 +306,8 @@ void RISCVDAGToDAGISel::addVectorLoadStoreOperands(
307
306
}
308
307
309
308
if (IsMasked) {
310
- // Mask needs to be copied to V0.
311
309
SDValue Mask = Node->getOperand (CurOp++);
312
- Chain = CurDAG->getCopyToReg (Chain, DL, RISCV::V0, Mask, SDValue ());
313
- Glue = Chain.getValue (1 );
314
- Operands.push_back (CurDAG->getRegister (RISCV::V0, Mask.getValueType ()));
310
+ Operands.push_back (Mask);
315
311
}
316
312
SDValue VL;
317
313
selectVLOp (Node->getOperand (CurOp++), VL);
@@ -333,8 +329,6 @@ void RISCVDAGToDAGISel::addVectorLoadStoreOperands(
333
329
}
334
330
335
331
Operands.push_back (Chain); // Chain.
336
- if (Glue)
337
- Operands.push_back (Glue);
338
332
}
339
333
340
334
void RISCVDAGToDAGISel::selectVLSEG (SDNode *Node, bool IsMasked,
@@ -1670,20 +1664,14 @@ void RISCVDAGToDAGISel::Select(SDNode *Node) {
1670
1664
return ;
1671
1665
}
1672
1666
1673
- // Mask needs to be copied to V0.
1674
- SDValue Chain = CurDAG->getCopyToReg (CurDAG->getEntryNode (), DL,
1675
- RISCV::V0, Mask, SDValue ());
1676
- SDValue Glue = Chain.getValue (1 );
1677
- SDValue V0 = CurDAG->getRegister (RISCV::V0, VT);
1678
-
1679
1667
// Otherwise use
1680
1668
// vmslt{u}.vx vd, va, x, v0.t; vmxor.mm vd, vd, v0
1681
1669
// The result is mask undisturbed.
1682
1670
// We use the same instructions to emulate mask agnostic behavior, because
1683
1671
// the agnostic result can be either undisturbed or all 1.
1684
1672
SDValue Cmp = SDValue (
1685
1673
CurDAG->getMachineNode (VMSLTMaskOpcode, DL, VT,
1686
- {MaskedOff, Src1, Src2, V0 , VL, SEW, Glue }),
1674
+ {MaskedOff, Src1, Src2, Mask , VL, SEW}),
1687
1675
0 );
1688
1676
// vmxor.mm vd, vd, v0 is used to update active value.
1689
1677
ReplaceNode (Node, CurDAG->getMachineNode (VMXOROpcode, DL, VT,
@@ -3426,32 +3414,7 @@ bool RISCVDAGToDAGISel::doPeepholeSExtW(SDNode *N) {
3426
3414
return false ;
3427
3415
}
3428
3416
3429
- static bool usesAllOnesMask (SDValue MaskOp, SDValue GlueOp) {
3430
- // Check that we're using V0 as a mask register.
3431
- if (!isa<RegisterSDNode>(MaskOp) ||
3432
- cast<RegisterSDNode>(MaskOp)->getReg () != RISCV::V0)
3433
- return false ;
3434
-
3435
- // The glued user defines V0.
3436
- const auto *Glued = GlueOp.getNode ();
3437
-
3438
- if (!Glued || Glued->getOpcode () != ISD::CopyToReg)
3439
- return false ;
3440
-
3441
- // Check that we're defining V0 as a mask register.
3442
- if (!isa<RegisterSDNode>(Glued->getOperand (1 )) ||
3443
- cast<RegisterSDNode>(Glued->getOperand (1 ))->getReg () != RISCV::V0)
3444
- return false ;
3445
-
3446
- // Check the instruction defining V0; it needs to be a VMSET pseudo.
3447
- SDValue MaskSetter = Glued->getOperand (2 );
3448
-
3449
- // Sometimes the VMSET is wrapped in a COPY_TO_REGCLASS, e.g. if the mask came
3450
- // from an extract_subvector or insert_subvector.
3451
- if (MaskSetter->isMachineOpcode () &&
3452
- MaskSetter->getMachineOpcode () == RISCV::COPY_TO_REGCLASS)
3453
- MaskSetter = MaskSetter->getOperand (0 );
3454
-
3417
+ static bool usesAllOnesMask (SDValue MaskOp) {
3455
3418
const auto IsVMSet = [](unsigned Opc) {
3456
3419
return Opc == RISCV::PseudoVMSET_M_B1 || Opc == RISCV::PseudoVMSET_M_B16 ||
3457
3420
Opc == RISCV::PseudoVMSET_M_B2 || Opc == RISCV::PseudoVMSET_M_B32 ||
@@ -3462,14 +3425,13 @@ static bool usesAllOnesMask(SDValue MaskOp, SDValue GlueOp) {
3462
3425
// TODO: Check that the VMSET is the expected bitwidth? The pseudo has
3463
3426
// undefined behaviour if it's the wrong bitwidth, so we could choose to
3464
3427
// assume that it's all-ones? Same applies to its VL.
3465
- return MaskSetter ->isMachineOpcode () &&
3466
- IsVMSet (MaskSetter .getMachineOpcode ());
3428
+ return MaskOp ->isMachineOpcode () &&
3429
+ IsVMSet (MaskOp .getMachineOpcode ());
3467
3430
}
3468
3431
3469
3432
// Return true if we can make sure mask of N is all-ones mask.
3470
3433
static bool usesAllOnesMask (SDNode *N, unsigned MaskOpIdx) {
3471
- return usesAllOnesMask (N->getOperand (MaskOpIdx),
3472
- N->getOperand (N->getNumOperands () - 1 ));
3434
+ return usesAllOnesMask (N->getOperand (MaskOpIdx));
3473
3435
}
3474
3436
3475
3437
static bool isImplicitDef (SDValue V) {
@@ -3515,10 +3477,10 @@ bool RISCVDAGToDAGISel::doPeepholeMaskedRVV(MachineSDNode *N) {
3515
3477
Ops.push_back (Op);
3516
3478
}
3517
3479
3518
- // Transitively apply any node glued to our new node.
3519
- const auto *Glued = N->getGluedNode ();
3520
- if (auto *TGlued = Glued->getGluedNode ())
3521
- Ops.push_back (SDValue (TGlued, TGlued->getNumValues () - 1 ));
3480
+ // // Transitively apply any node glued to our new node.
3481
+ // const auto *Glued = N->getGluedNode();
3482
+ // if (auto *TGlued = Glued->getGluedNode())
3483
+ // Ops.push_back(SDValue(TGlued, TGlued->getNumValues() - 1));
3522
3484
3523
3485
MachineSDNode *Result =
3524
3486
CurDAG->getMachineNode (Opc, SDLoc (N), N->getVTList (), Ops);
@@ -3584,7 +3546,7 @@ static unsigned GetVMSetForLMul(RISCVII::VLMUL LMUL) {
3584
3546
// The resulting policy is the effective policy the vmerge would have had,
3585
3547
// i.e. whether or not it's merge operand was implicit-def.
3586
3548
bool RISCVDAGToDAGISel::performCombineVMergeAndVOps (SDNode *N) {
3587
- SDValue Merge, False, True, VL, Mask, Glue ;
3549
+ SDValue Merge, False, True, VL, Mask;
3588
3550
// A vmv.v.v is equivalent to a vmerge with an all-ones mask.
3589
3551
if (IsVMv (N)) {
3590
3552
Merge = N->getOperand (0 );
@@ -3600,11 +3562,7 @@ bool RISCVDAGToDAGISel::performCombineVMergeAndVOps(SDNode *N) {
3600
3562
True = N->getOperand (2 );
3601
3563
Mask = N->getOperand (3 );
3602
3564
VL = N->getOperand (4 );
3603
- // We always have a glue node for the mask at v0.
3604
- Glue = N->getOperand (N->getNumOperands () - 1 );
3605
3565
}
3606
- assert (!Mask || cast<RegisterSDNode>(Mask)->getReg () == RISCV::V0);
3607
- assert (!Glue || Glue.getValueType () == MVT::Glue);
3608
3566
3609
3567
// We require that either merge and false are the same, or that merge
3610
3568
// is undefined.
@@ -3639,7 +3597,7 @@ bool RISCVDAGToDAGISel::performCombineVMergeAndVOps(SDNode *N) {
3639
3597
3640
3598
// When Mask is not a true mask, this transformation is illegal for some
3641
3599
// operations whose results are affected by mask, like viota.m.
3642
- if (Info->MaskAffectsResult && Mask && !usesAllOnesMask (Mask, Glue ))
3600
+ if (Info->MaskAffectsResult && Mask && !usesAllOnesMask (Mask))
3643
3601
return false ;
3644
3602
3645
3603
// If True has a merge operand then it needs to be the same as vmerge's False,
@@ -3664,7 +3622,7 @@ bool RISCVDAGToDAGISel::performCombineVMergeAndVOps(SDNode *N) {
3664
3622
return false ;
3665
3623
// FIXME: Support mask agnostic True instruction which would have an
3666
3624
// undef merge operand.
3667
- if (Mask && !usesAllOnesMask (Mask, Glue ))
3625
+ if (Mask && !usesAllOnesMask (Mask))
3668
3626
return false ;
3669
3627
}
3670
3628
@@ -3691,8 +3649,6 @@ bool RISCVDAGToDAGISel::performCombineVMergeAndVOps(SDNode *N) {
3691
3649
if (Mask)
3692
3650
LoopWorklist.push_back (Mask.getNode ());
3693
3651
LoopWorklist.push_back (VL.getNode ());
3694
- if (Glue)
3695
- LoopWorklist.push_back (Glue.getNode ());
3696
3652
if (SDNode::hasPredecessorHelper (True.getNode (), Visited, LoopWorklist))
3697
3653
return false ;
3698
3654
}
@@ -3737,25 +3693,16 @@ bool RISCVDAGToDAGISel::performCombineVMergeAndVOps(SDNode *N) {
3737
3693
3738
3694
// From the preconditions we checked above, we know the mask and thus glue
3739
3695
// for the result node will be taken from True.
3740
- if (IsMasked) {
3696
+ if (IsMasked)
3741
3697
Mask = True->getOperand (Info->MaskOpIdx );
3742
- Glue = True->getOperand (True->getNumOperands () - 1 );
3743
- assert (Glue.getValueType () == MVT::Glue);
3744
- }
3745
3698
// If we end up using the vmerge mask the vmerge is actually a vmv.v.v, create
3746
3699
// an all-ones mask to use.
3747
3700
else if (IsVMv (N)) {
3748
3701
unsigned TSFlags = TII->get (N->getMachineOpcode ()).TSFlags ;
3749
3702
unsigned VMSetOpc = GetVMSetForLMul (RISCVII::getLMul (TSFlags));
3750
3703
ElementCount EC = N->getValueType (0 ).getVectorElementCount ();
3751
3704
MVT MaskVT = MVT::getVectorVT (MVT::i1, EC);
3752
-
3753
- SDValue AllOnesMask =
3754
- SDValue (CurDAG->getMachineNode (VMSetOpc, DL, MaskVT, VL, SEW), 0 );
3755
- SDValue MaskCopy = CurDAG->getCopyToReg (CurDAG->getEntryNode (), DL,
3756
- RISCV::V0, AllOnesMask, SDValue ());
3757
- Mask = CurDAG->getRegister (RISCV::V0, MaskVT);
3758
- Glue = MaskCopy.getValue (1 );
3705
+ Mask = SDValue (CurDAG->getMachineNode (VMSetOpc, DL, MaskVT, VL, SEW), 0 );
3759
3706
}
3760
3707
3761
3708
unsigned MaskedOpc = Info->MaskedPseudo ;
@@ -3806,9 +3753,6 @@ bool RISCVDAGToDAGISel::performCombineVMergeAndVOps(SDNode *N) {
3806
3753
if (HasChainOp)
3807
3754
Ops.push_back (True.getOperand (TrueChainOpIdx));
3808
3755
3809
- // Add the glue for the CopyToReg of mask->v0.
3810
- Ops.push_back (Glue);
3811
-
3812
3756
MachineSDNode *Result =
3813
3757
CurDAG->getMachineNode (MaskedOpc, DL, True->getVTList (), Ops);
3814
3758
Result->setFlags (True->getFlags ());
0 commit comments