@@ -254,7 +254,6 @@ void RISCVDAGToDAGISel::addVectorLoadStoreOperands(
254
254
bool IsMasked, bool IsStridedOrIndexed, SmallVectorImpl<SDValue> &Operands,
255
255
bool IsLoad, MVT *IndexVT) {
256
256
SDValue Chain = Node->getOperand (0 );
257
- SDValue Glue;
258
257
259
258
Operands.push_back (Node->getOperand (CurOp++)); // Base pointer.
260
259
@@ -265,11 +264,8 @@ void RISCVDAGToDAGISel::addVectorLoadStoreOperands(
265
264
}
266
265
267
266
if (IsMasked) {
268
- // Mask needs to be copied to V0.
269
267
SDValue Mask = Node->getOperand (CurOp++);
270
- Chain = CurDAG->getCopyToReg (Chain, DL, RISCV::V0, Mask, SDValue ());
271
- Glue = Chain.getValue (1 );
272
- Operands.push_back (CurDAG->getRegister (RISCV::V0, Mask.getValueType ()));
268
+ Operands.push_back (Mask);
273
269
}
274
270
SDValue VL;
275
271
selectVLOp (Node->getOperand (CurOp++), VL);
@@ -291,8 +287,6 @@ void RISCVDAGToDAGISel::addVectorLoadStoreOperands(
291
287
}
292
288
293
289
Operands.push_back (Chain); // Chain.
294
- if (Glue)
295
- Operands.push_back (Glue);
296
290
}
297
291
298
292
void RISCVDAGToDAGISel::selectVLSEG (SDNode *Node, unsigned NF, bool IsMasked,
@@ -1844,19 +1838,13 @@ void RISCVDAGToDAGISel::Select(SDNode *Node) {
1844
1838
return ;
1845
1839
}
1846
1840
1847
- // Mask needs to be copied to V0.
1848
- SDValue Chain = CurDAG->getCopyToReg (CurDAG->getEntryNode (), DL,
1849
- RISCV::V0, Mask, SDValue ());
1850
- SDValue Glue = Chain.getValue (1 );
1851
- SDValue V0 = CurDAG->getRegister (RISCV::V0, VT);
1852
-
1853
1841
if (IsCmpConstant) {
1854
1842
SDValue Imm =
1855
1843
selectImm (CurDAG, SDLoc (Src2), XLenVT, CVal - 1 , *Subtarget);
1856
1844
1857
1845
ReplaceNode (Node, CurDAG->getMachineNode (
1858
1846
VMSGTMaskOpcode, DL, VT,
1859
- {MaskedOff, Src1, Imm, V0 , VL, SEW, Glue }));
1847
+ {MaskedOff, Src1, Imm, Mask , VL, SEW}));
1860
1848
return ;
1861
1849
}
1862
1850
@@ -1867,7 +1855,7 @@ void RISCVDAGToDAGISel::Select(SDNode *Node) {
1867
1855
// the agnostic result can be either undisturbed or all 1.
1868
1856
SDValue Cmp = SDValue (
1869
1857
CurDAG->getMachineNode (VMSLTMaskOpcode, DL, VT,
1870
- {MaskedOff, Src1, Src2, V0 , VL, SEW, Glue }),
1858
+ {MaskedOff, Src1, Src2, Mask , VL, SEW}),
1871
1859
0 );
1872
1860
// vmxor.mm vd, vd, v0 is used to update active value.
1873
1861
ReplaceNode (Node, CurDAG->getMachineNode (VMXOROpcode, DL, VT,
@@ -3287,12 +3275,10 @@ static bool vectorPseudoHasAllNBitUsers(SDNode *User, unsigned UserOpNo,
3287
3275
return false ;
3288
3276
assert (RISCVII::hasVLOp (TSFlags));
3289
3277
3290
- bool HasGlueOp = User->getGluedNode () != nullptr ;
3291
- unsigned ChainOpIdx = User->getNumOperands () - HasGlueOp - 1 ;
3278
+ unsigned ChainOpIdx = User->getNumOperands () - 1 ;
3292
3279
bool HasChainOp = User->getOperand (ChainOpIdx).getValueType () == MVT::Other;
3293
3280
bool HasVecPolicyOp = RISCVII::hasVecPolicyOp (TSFlags);
3294
- unsigned VLIdx =
3295
- User->getNumOperands () - HasVecPolicyOp - HasChainOp - HasGlueOp - 2 ;
3281
+ unsigned VLIdx = User->getNumOperands () - HasVecPolicyOp - HasChainOp - 2 ;
3296
3282
const unsigned Log2SEW = User->getConstantOperandVal (VLIdx + 1 );
3297
3283
3298
3284
if (UserOpNo == VLIdx)
@@ -3759,43 +3745,7 @@ bool RISCVDAGToDAGISel::doPeepholeSExtW(SDNode *N) {
3759
3745
return false ;
3760
3746
}
3761
3747
3762
- // After ISel, a vector pseudo's mask will be copied to V0 via a CopyToReg
3763
- // that's glued to the pseudo. This tries to look up the value that was copied
3764
- // to V0.
3765
- static SDValue getMaskSetter (SDValue MaskOp, SDValue GlueOp) {
3766
- // Check that we're using V0 as a mask register.
3767
- if (!isa<RegisterSDNode>(MaskOp) ||
3768
- cast<RegisterSDNode>(MaskOp)->getReg () != RISCV::V0)
3769
- return SDValue ();
3770
-
3771
- // The glued user defines V0.
3772
- const auto *Glued = GlueOp.getNode ();
3773
-
3774
- if (!Glued || Glued->getOpcode () != ISD::CopyToReg)
3775
- return SDValue ();
3776
-
3777
- // Check that we're defining V0 as a mask register.
3778
- if (!isa<RegisterSDNode>(Glued->getOperand (1 )) ||
3779
- cast<RegisterSDNode>(Glued->getOperand (1 ))->getReg () != RISCV::V0)
3780
- return SDValue ();
3781
-
3782
- SDValue MaskSetter = Glued->getOperand (2 );
3783
-
3784
- // Sometimes the VMSET is wrapped in a COPY_TO_REGCLASS, e.g. if the mask came
3785
- // from an extract_subvector or insert_subvector.
3786
- if (MaskSetter->isMachineOpcode () &&
3787
- MaskSetter->getMachineOpcode () == RISCV::COPY_TO_REGCLASS)
3788
- MaskSetter = MaskSetter->getOperand (0 );
3789
-
3790
- return MaskSetter;
3791
- }
3792
-
3793
- static bool usesAllOnesMask (SDValue MaskOp, SDValue GlueOp) {
3794
- // Check the instruction defining V0; it needs to be a VMSET pseudo.
3795
- SDValue MaskSetter = getMaskSetter (MaskOp, GlueOp);
3796
- if (!MaskSetter)
3797
- return false ;
3798
-
3748
+ static bool usesAllOnesMask (SDValue MaskOp) {
3799
3749
const auto IsVMSet = [](unsigned Opc) {
3800
3750
return Opc == RISCV::PseudoVMSET_M_B1 || Opc == RISCV::PseudoVMSET_M_B16 ||
3801
3751
Opc == RISCV::PseudoVMSET_M_B2 || Opc == RISCV::PseudoVMSET_M_B32 ||
@@ -3806,14 +3756,7 @@ static bool usesAllOnesMask(SDValue MaskOp, SDValue GlueOp) {
3806
3756
// TODO: Check that the VMSET is the expected bitwidth? The pseudo has
3807
3757
// undefined behaviour if it's the wrong bitwidth, so we could choose to
3808
3758
// assume that it's all-ones? Same applies to its VL.
3809
- return MaskSetter->isMachineOpcode () &&
3810
- IsVMSet (MaskSetter.getMachineOpcode ());
3811
- }
3812
-
3813
- // Return true if we can make sure mask of N is all-ones mask.
3814
- static bool usesAllOnesMask (SDNode *N, unsigned MaskOpIdx) {
3815
- return usesAllOnesMask (N->getOperand (MaskOpIdx),
3816
- N->getOperand (N->getNumOperands () - 1 ));
3759
+ return MaskOp->isMachineOpcode () && IsVMSet (MaskOp.getMachineOpcode ());
3817
3760
}
3818
3761
3819
3762
static bool isImplicitDef (SDValue V) {
@@ -3829,17 +3772,15 @@ static bool isImplicitDef(SDValue V) {
3829
3772
}
3830
3773
3831
3774
// Optimize masked RVV pseudo instructions with a known all-ones mask to their
3832
- // corresponding "unmasked" pseudo versions. The mask we're interested in will
3833
- // take the form of a V0 physical register operand, with a glued
3834
- // register-setting instruction.
3775
+ // corresponding "unmasked" pseudo versions.
3835
3776
bool RISCVDAGToDAGISel::doPeepholeMaskedRVV (MachineSDNode *N) {
3836
3777
const RISCV::RISCVMaskedPseudoInfo *I =
3837
3778
RISCV::getMaskedPseudoInfo (N->getMachineOpcode ());
3838
3779
if (!I)
3839
3780
return false ;
3840
3781
3841
3782
unsigned MaskOpIdx = I->MaskOpIdx ;
3842
- if (!usesAllOnesMask (N, MaskOpIdx))
3783
+ if (!usesAllOnesMask (N-> getOperand ( MaskOpIdx) ))
3843
3784
return false ;
3844
3785
3845
3786
// There are two classes of pseudos in the table - compares and
@@ -3863,18 +3804,13 @@ bool RISCVDAGToDAGISel::doPeepholeMaskedRVV(MachineSDNode *N) {
3863
3804
// Skip the passthru operand at index 0 if the unmasked don't have one.
3864
3805
bool ShouldSkip = !HasPassthru && MaskedHasPassthru;
3865
3806
for (unsigned I = ShouldSkip, E = N->getNumOperands (); I != E; I++) {
3866
- // Skip the mask, and the Glue.
3807
+ // Skip the mask
3867
3808
SDValue Op = N->getOperand (I);
3868
- if (I == MaskOpIdx || Op. getValueType () == MVT::Glue )
3809
+ if (I == MaskOpIdx)
3869
3810
continue ;
3870
3811
Ops.push_back (Op);
3871
3812
}
3872
3813
3873
- // Transitively apply any node glued to our new node.
3874
- const auto *Glued = N->getGluedNode ();
3875
- if (auto *TGlued = Glued->getGluedNode ())
3876
- Ops.push_back (SDValue (TGlued, TGlued->getNumValues () - 1 ));
3877
-
3878
3814
MachineSDNode *Result =
3879
3815
CurDAG->getMachineNode (Opc, SDLoc (N), N->getVTList (), Ops);
3880
3816
@@ -3910,17 +3846,13 @@ static bool IsVMerge(SDNode *N) {
3910
3846
// The resulting policy is the effective policy the vmerge would have had,
3911
3847
// i.e. whether or not it's passthru operand was implicit-def.
3912
3848
bool RISCVDAGToDAGISel::performCombineVMergeAndVOps (SDNode *N) {
3913
- SDValue Passthru, False, True, VL, Mask, Glue ;
3849
+ SDValue Passthru, False, True, VL, Mask;
3914
3850
assert (IsVMerge (N));
3915
3851
Passthru = N->getOperand (0 );
3916
3852
False = N->getOperand (1 );
3917
3853
True = N->getOperand (2 );
3918
3854
Mask = N->getOperand (3 );
3919
3855
VL = N->getOperand (4 );
3920
- // We always have a glue node for the mask at v0.
3921
- Glue = N->getOperand (N->getNumOperands () - 1 );
3922
- assert (cast<RegisterSDNode>(Mask)->getReg () == RISCV::V0);
3923
- assert (Glue.getValueType () == MVT::Glue);
3924
3856
3925
3857
// If the EEW of True is different from vmerge's SEW, then we can't fold.
3926
3858
if (True.getSimpleValueType () != N->getSimpleValueType (0 ))
@@ -3963,12 +3895,7 @@ bool RISCVDAGToDAGISel::performCombineVMergeAndVOps(SDNode *N) {
3963
3895
if (TII->get (TrueOpc).hasUnmodeledSideEffects ())
3964
3896
return false ;
3965
3897
3966
- // The last operand of a masked instruction may be glued.
3967
- bool HasGlueOp = True->getGluedNode () != nullptr ;
3968
-
3969
- // The chain operand may exist either before the glued operands or in the last
3970
- // position.
3971
- unsigned TrueChainOpIdx = True.getNumOperands () - HasGlueOp - 1 ;
3898
+ unsigned TrueChainOpIdx = True.getNumOperands () - 1 ;
3972
3899
bool HasChainOp =
3973
3900
True.getOperand (TrueChainOpIdx).getValueType () == MVT::Other;
3974
3901
@@ -3980,15 +3907,14 @@ bool RISCVDAGToDAGISel::performCombineVMergeAndVOps(SDNode *N) {
3980
3907
LoopWorklist.push_back (False.getNode ());
3981
3908
LoopWorklist.push_back (Mask.getNode ());
3982
3909
LoopWorklist.push_back (VL.getNode ());
3983
- LoopWorklist.push_back (Glue.getNode ());
3984
3910
if (SDNode::hasPredecessorHelper (True.getNode (), Visited, LoopWorklist))
3985
3911
return false ;
3986
3912
}
3987
3913
3988
3914
// The vector policy operand may be present for masked intrinsics
3989
3915
bool HasVecPolicyOp = RISCVII::hasVecPolicyOp (TrueTSFlags);
3990
3916
unsigned TrueVLIndex =
3991
- True.getNumOperands () - HasVecPolicyOp - HasChainOp - HasGlueOp - 2 ;
3917
+ True.getNumOperands () - HasVecPolicyOp - HasChainOp - 2 ;
3992
3918
SDValue TrueVL = True.getOperand (TrueVLIndex);
3993
3919
SDValue SEW = True.getOperand (TrueVLIndex + 1 );
3994
3920
@@ -4020,7 +3946,7 @@ bool RISCVDAGToDAGISel::performCombineVMergeAndVOps(SDNode *N) {
4020
3946
if (RISCVII::elementsDependOnVL (TrueBaseMCID.TSFlags ) && (TrueVL != VL))
4021
3947
return false ;
4022
3948
if (RISCVII::elementsDependOnMask (TrueBaseMCID.TSFlags ) &&
4023
- (Mask && !usesAllOnesMask (Mask, Glue )))
3949
+ (Mask && !usesAllOnesMask (Mask)))
4024
3950
return false ;
4025
3951
4026
3952
// Make sure it doesn't raise any observable fp exceptions, since changing the
@@ -4077,9 +4003,6 @@ bool RISCVDAGToDAGISel::performCombineVMergeAndVOps(SDNode *N) {
4077
4003
if (HasChainOp)
4078
4004
Ops.push_back (True.getOperand (TrueChainOpIdx));
4079
4005
4080
- // Add the glue for the CopyToReg of mask->v0.
4081
- Ops.push_back (Glue);
4082
-
4083
4006
MachineSDNode *Result =
4084
4007
CurDAG->getMachineNode (MaskedOpc, DL, True->getVTList (), Ops);
4085
4008
Result->setFlags (True->getFlags ());
0 commit comments