@@ -241,7 +241,6 @@ void RISCVDAGToDAGISel::addVectorLoadStoreOperands(
241
241
bool IsMasked, bool IsStridedOrIndexed, SmallVectorImpl<SDValue> &Operands,
242
242
bool IsLoad, MVT *IndexVT) {
243
243
SDValue Chain = Node->getOperand (0 );
244
- SDValue Glue;
245
244
246
245
Operands.push_back (Node->getOperand (CurOp++)); // Base pointer.
247
246
@@ -252,11 +251,8 @@ void RISCVDAGToDAGISel::addVectorLoadStoreOperands(
252
251
}
253
252
254
253
if (IsMasked) {
255
- // Mask needs to be copied to V0.
256
254
SDValue Mask = Node->getOperand (CurOp++);
257
- Chain = CurDAG->getCopyToReg (Chain, DL, RISCV::V0, Mask, SDValue ());
258
- Glue = Chain.getValue (1 );
259
- Operands.push_back (CurDAG->getRegister (RISCV::V0, Mask.getValueType ()));
255
+ Operands.push_back (Mask);
260
256
}
261
257
SDValue VL;
262
258
selectVLOp (Node->getOperand (CurOp++), VL);
@@ -278,8 +274,6 @@ void RISCVDAGToDAGISel::addVectorLoadStoreOperands(
278
274
}
279
275
280
276
Operands.push_back (Chain); // Chain.
281
- if (Glue)
282
- Operands.push_back (Glue);
283
277
}
284
278
285
279
void RISCVDAGToDAGISel::selectVLSEG (SDNode *Node, unsigned NF, bool IsMasked,
@@ -1831,19 +1825,13 @@ void RISCVDAGToDAGISel::Select(SDNode *Node) {
1831
1825
return ;
1832
1826
}
1833
1827
1834
- // Mask needs to be copied to V0.
1835
- SDValue Chain = CurDAG->getCopyToReg (CurDAG->getEntryNode (), DL,
1836
- RISCV::V0, Mask, SDValue ());
1837
- SDValue Glue = Chain.getValue (1 );
1838
- SDValue V0 = CurDAG->getRegister (RISCV::V0, VT);
1839
-
1840
1828
if (IsCmpConstant) {
1841
1829
SDValue Imm =
1842
1830
selectImm (CurDAG, SDLoc (Src2), XLenVT, CVal - 1 , *Subtarget);
1843
1831
1844
1832
ReplaceNode (Node, CurDAG->getMachineNode (
1845
1833
VMSGTMaskOpcode, DL, VT,
1846
- {MaskedOff, Src1, Imm, V0 , VL, SEW, Glue }));
1834
+ {MaskedOff, Src1, Imm, Mask , VL, SEW}));
1847
1835
return ;
1848
1836
}
1849
1837
@@ -1854,7 +1842,7 @@ void RISCVDAGToDAGISel::Select(SDNode *Node) {
1854
1842
// the agnostic result can be either undisturbed or all 1.
1855
1843
SDValue Cmp = SDValue (
1856
1844
CurDAG->getMachineNode (VMSLTMaskOpcode, DL, VT,
1857
- {MaskedOff, Src1, Src2, V0 , VL, SEW, Glue }),
1845
+ {MaskedOff, Src1, Src2, Mask , VL, SEW}),
1858
1846
0 );
1859
1847
// vmxor.mm vd, vd, v0 is used to update active value.
1860
1848
ReplaceNode (Node, CurDAG->getMachineNode (VMXOROpcode, DL, VT,
@@ -3274,12 +3262,10 @@ static bool vectorPseudoHasAllNBitUsers(SDNode *User, unsigned UserOpNo,
3274
3262
return false ;
3275
3263
assert (RISCVII::hasVLOp (TSFlags));
3276
3264
3277
- bool HasGlueOp = User->getGluedNode () != nullptr ;
3278
- unsigned ChainOpIdx = User->getNumOperands () - HasGlueOp - 1 ;
3265
+ unsigned ChainOpIdx = User->getNumOperands () - 1 ;
3279
3266
bool HasChainOp = User->getOperand (ChainOpIdx).getValueType () == MVT::Other;
3280
3267
bool HasVecPolicyOp = RISCVII::hasVecPolicyOp (TSFlags);
3281
- unsigned VLIdx =
3282
- User->getNumOperands () - HasVecPolicyOp - HasChainOp - HasGlueOp - 2 ;
3268
+ unsigned VLIdx = User->getNumOperands () - HasVecPolicyOp - HasChainOp - 2 ;
3283
3269
const unsigned Log2SEW = User->getConstantOperandVal (VLIdx + 1 );
3284
3270
3285
3271
if (UserOpNo == VLIdx)
@@ -3746,43 +3732,7 @@ bool RISCVDAGToDAGISel::doPeepholeSExtW(SDNode *N) {
3746
3732
return false ;
3747
3733
}
3748
3734
3749
- // After ISel, a vector pseudo's mask will be copied to V0 via a CopyToReg
3750
- // that's glued to the pseudo. This tries to look up the value that was copied
3751
- // to V0.
3752
- static SDValue getMaskSetter (SDValue MaskOp, SDValue GlueOp) {
3753
- // Check that we're using V0 as a mask register.
3754
- if (!isa<RegisterSDNode>(MaskOp) ||
3755
- cast<RegisterSDNode>(MaskOp)->getReg () != RISCV::V0)
3756
- return SDValue ();
3757
-
3758
- // The glued user defines V0.
3759
- const auto *Glued = GlueOp.getNode ();
3760
-
3761
- if (!Glued || Glued->getOpcode () != ISD::CopyToReg)
3762
- return SDValue ();
3763
-
3764
- // Check that we're defining V0 as a mask register.
3765
- if (!isa<RegisterSDNode>(Glued->getOperand (1 )) ||
3766
- cast<RegisterSDNode>(Glued->getOperand (1 ))->getReg () != RISCV::V0)
3767
- return SDValue ();
3768
-
3769
- SDValue MaskSetter = Glued->getOperand (2 );
3770
-
3771
- // Sometimes the VMSET is wrapped in a COPY_TO_REGCLASS, e.g. if the mask came
3772
- // from an extract_subvector or insert_subvector.
3773
- if (MaskSetter->isMachineOpcode () &&
3774
- MaskSetter->getMachineOpcode () == RISCV::COPY_TO_REGCLASS)
3775
- MaskSetter = MaskSetter->getOperand (0 );
3776
-
3777
- return MaskSetter;
3778
- }
3779
-
3780
- static bool usesAllOnesMask (SDValue MaskOp, SDValue GlueOp) {
3781
- // Check the instruction defining V0; it needs to be a VMSET pseudo.
3782
- SDValue MaskSetter = getMaskSetter (MaskOp, GlueOp);
3783
- if (!MaskSetter)
3784
- return false ;
3785
-
3735
+ static bool usesAllOnesMask (SDValue MaskOp) {
3786
3736
const auto IsVMSet = [](unsigned Opc) {
3787
3737
return Opc == RISCV::PseudoVMSET_M_B1 || Opc == RISCV::PseudoVMSET_M_B16 ||
3788
3738
Opc == RISCV::PseudoVMSET_M_B2 || Opc == RISCV::PseudoVMSET_M_B32 ||
@@ -3793,14 +3743,7 @@ static bool usesAllOnesMask(SDValue MaskOp, SDValue GlueOp) {
3793
3743
// TODO: Check that the VMSET is the expected bitwidth? The pseudo has
3794
3744
// undefined behaviour if it's the wrong bitwidth, so we could choose to
3795
3745
// assume that it's all-ones? Same applies to its VL.
3796
- return MaskSetter->isMachineOpcode () &&
3797
- IsVMSet (MaskSetter.getMachineOpcode ());
3798
- }
3799
-
3800
- // Return true if we can make sure mask of N is all-ones mask.
3801
- static bool usesAllOnesMask (SDNode *N, unsigned MaskOpIdx) {
3802
- return usesAllOnesMask (N->getOperand (MaskOpIdx),
3803
- N->getOperand (N->getNumOperands () - 1 ));
3746
+ return MaskOp->isMachineOpcode () && IsVMSet (MaskOp.getMachineOpcode ());
3804
3747
}
3805
3748
3806
3749
static bool isImplicitDef (SDValue V) {
@@ -3816,17 +3759,15 @@ static bool isImplicitDef(SDValue V) {
3816
3759
}
3817
3760
3818
3761
// Optimize masked RVV pseudo instructions with a known all-ones mask to their
3819
- // corresponding "unmasked" pseudo versions. The mask we're interested in will
3820
- // take the form of a V0 physical register operand, with a glued
3821
- // register-setting instruction.
3762
+ // corresponding "unmasked" pseudo versions.
3822
3763
bool RISCVDAGToDAGISel::doPeepholeMaskedRVV (MachineSDNode *N) {
3823
3764
const RISCV::RISCVMaskedPseudoInfo *I =
3824
3765
RISCV::getMaskedPseudoInfo (N->getMachineOpcode ());
3825
3766
if (!I)
3826
3767
return false ;
3827
3768
3828
3769
unsigned MaskOpIdx = I->MaskOpIdx ;
3829
- if (!usesAllOnesMask (N, MaskOpIdx))
3770
+ if (!usesAllOnesMask (N-> getOperand ( MaskOpIdx) ))
3830
3771
return false ;
3831
3772
3832
3773
// There are two classes of pseudos in the table - compares and
@@ -3850,18 +3791,13 @@ bool RISCVDAGToDAGISel::doPeepholeMaskedRVV(MachineSDNode *N) {
3850
3791
// Skip the passthru operand at index 0 if the unmasked don't have one.
3851
3792
bool ShouldSkip = !HasPassthru && MaskedHasPassthru;
3852
3793
for (unsigned I = ShouldSkip, E = N->getNumOperands (); I != E; I++) {
3853
- // Skip the mask, and the Glue.
3794
+ // Skip the mask
3854
3795
SDValue Op = N->getOperand (I);
3855
- if (I == MaskOpIdx || Op. getValueType () == MVT::Glue )
3796
+ if (I == MaskOpIdx)
3856
3797
continue ;
3857
3798
Ops.push_back (Op);
3858
3799
}
3859
3800
3860
- // Transitively apply any node glued to our new node.
3861
- const auto *Glued = N->getGluedNode ();
3862
- if (auto *TGlued = Glued->getGluedNode ())
3863
- Ops.push_back (SDValue (TGlued, TGlued->getNumValues () - 1 ));
3864
-
3865
3801
MachineSDNode *Result =
3866
3802
CurDAG->getMachineNode (Opc, SDLoc (N), N->getVTList (), Ops);
3867
3803
@@ -3897,17 +3833,13 @@ static bool IsVMerge(SDNode *N) {
3897
3833
// The resulting policy is the effective policy the vmerge would have had,
3898
3834
// i.e. whether or not it's passthru operand was implicit-def.
3899
3835
bool RISCVDAGToDAGISel::performCombineVMergeAndVOps (SDNode *N) {
3900
- SDValue Passthru, False, True, VL, Mask, Glue ;
3836
+ SDValue Passthru, False, True, VL, Mask;
3901
3837
assert (IsVMerge (N));
3902
3838
Passthru = N->getOperand (0 );
3903
3839
False = N->getOperand (1 );
3904
3840
True = N->getOperand (2 );
3905
3841
Mask = N->getOperand (3 );
3906
3842
VL = N->getOperand (4 );
3907
- // We always have a glue node for the mask at v0.
3908
- Glue = N->getOperand (N->getNumOperands () - 1 );
3909
- assert (cast<RegisterSDNode>(Mask)->getReg () == RISCV::V0);
3910
- assert (Glue.getValueType () == MVT::Glue);
3911
3843
3912
3844
// If the EEW of True is different from vmerge's SEW, then we can't fold.
3913
3845
if (True.getSimpleValueType () != N->getSimpleValueType (0 ))
@@ -3950,12 +3882,7 @@ bool RISCVDAGToDAGISel::performCombineVMergeAndVOps(SDNode *N) {
3950
3882
if (TII->get (TrueOpc).hasUnmodeledSideEffects ())
3951
3883
return false ;
3952
3884
3953
- // The last operand of a masked instruction may be glued.
3954
- bool HasGlueOp = True->getGluedNode () != nullptr ;
3955
-
3956
- // The chain operand may exist either before the glued operands or in the last
3957
- // position.
3958
- unsigned TrueChainOpIdx = True.getNumOperands () - HasGlueOp - 1 ;
3885
+ unsigned TrueChainOpIdx = True.getNumOperands () - 1 ;
3959
3886
bool HasChainOp =
3960
3887
True.getOperand (TrueChainOpIdx).getValueType () == MVT::Other;
3961
3888
@@ -3967,15 +3894,14 @@ bool RISCVDAGToDAGISel::performCombineVMergeAndVOps(SDNode *N) {
3967
3894
LoopWorklist.push_back (False.getNode ());
3968
3895
LoopWorklist.push_back (Mask.getNode ());
3969
3896
LoopWorklist.push_back (VL.getNode ());
3970
- LoopWorklist.push_back (Glue.getNode ());
3971
3897
if (SDNode::hasPredecessorHelper (True.getNode (), Visited, LoopWorklist))
3972
3898
return false ;
3973
3899
}
3974
3900
3975
3901
// The vector policy operand may be present for masked intrinsics
3976
3902
bool HasVecPolicyOp = RISCVII::hasVecPolicyOp (TrueTSFlags);
3977
3903
unsigned TrueVLIndex =
3978
- True.getNumOperands () - HasVecPolicyOp - HasChainOp - HasGlueOp - 2 ;
3904
+ True.getNumOperands () - HasVecPolicyOp - HasChainOp - 2 ;
3979
3905
SDValue TrueVL = True.getOperand (TrueVLIndex);
3980
3906
SDValue SEW = True.getOperand (TrueVLIndex + 1 );
3981
3907
@@ -4007,7 +3933,7 @@ bool RISCVDAGToDAGISel::performCombineVMergeAndVOps(SDNode *N) {
4007
3933
if (RISCVII::elementsDependOnVL (TrueBaseMCID.TSFlags ) && (TrueVL != VL))
4008
3934
return false ;
4009
3935
if (RISCVII::elementsDependOnMask (TrueBaseMCID.TSFlags ) &&
4010
- (Mask && !usesAllOnesMask (Mask, Glue )))
3936
+ (Mask && !usesAllOnesMask (Mask)))
4011
3937
return false ;
4012
3938
4013
3939
// Make sure it doesn't raise any observable fp exceptions, since changing the
@@ -4064,9 +3990,6 @@ bool RISCVDAGToDAGISel::performCombineVMergeAndVOps(SDNode *N) {
4064
3990
if (HasChainOp)
4065
3991
Ops.push_back (True.getOperand (TrueChainOpIdx));
4066
3992
4067
- // Add the glue for the CopyToReg of mask->v0.
4068
- Ops.push_back (Glue);
4069
-
4070
3993
MachineSDNode *Result =
4071
3994
CurDAG->getMachineNode (MaskedOpc, DL, True->getVTList (), Ops);
4072
3995
Result->setFlags (True->getFlags ());
0 commit comments