@@ -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)
@@ -3739,43 +3725,7 @@ bool RISCVDAGToDAGISel::doPeepholeSExtW(SDNode *N) {
3739
3725
return false ;
3740
3726
}
3741
3727
3742
- // After ISel, a vector pseudo's mask will be copied to V0 via a CopyToReg
3743
- // that's glued to the pseudo. This tries to look up the value that was copied
3744
- // to V0.
3745
- static SDValue getMaskSetter (SDValue MaskOp, SDValue GlueOp) {
3746
- // Check that we're using V0 as a mask register.
3747
- if (!isa<RegisterSDNode>(MaskOp) ||
3748
- cast<RegisterSDNode>(MaskOp)->getReg () != RISCV::V0)
3749
- return SDValue ();
3750
-
3751
- // The glued user defines V0.
3752
- const auto *Glued = GlueOp.getNode ();
3753
-
3754
- if (!Glued || Glued->getOpcode () != ISD::CopyToReg)
3755
- return SDValue ();
3756
-
3757
- // Check that we're defining V0 as a mask register.
3758
- if (!isa<RegisterSDNode>(Glued->getOperand (1 )) ||
3759
- cast<RegisterSDNode>(Glued->getOperand (1 ))->getReg () != RISCV::V0)
3760
- return SDValue ();
3761
-
3762
- SDValue MaskSetter = Glued->getOperand (2 );
3763
-
3764
- // Sometimes the VMSET is wrapped in a COPY_TO_REGCLASS, e.g. if the mask came
3765
- // from an extract_subvector or insert_subvector.
3766
- if (MaskSetter->isMachineOpcode () &&
3767
- MaskSetter->getMachineOpcode () == RISCV::COPY_TO_REGCLASS)
3768
- MaskSetter = MaskSetter->getOperand (0 );
3769
-
3770
- return MaskSetter;
3771
- }
3772
-
3773
- static bool usesAllOnesMask (SDValue MaskOp, SDValue GlueOp) {
3774
- // Check the instruction defining V0; it needs to be a VMSET pseudo.
3775
- SDValue MaskSetter = getMaskSetter (MaskOp, GlueOp);
3776
- if (!MaskSetter)
3777
- return false ;
3778
-
3728
+ static bool usesAllOnesMask (SDValue MaskOp) {
3779
3729
const auto IsVMSet = [](unsigned Opc) {
3780
3730
return Opc == RISCV::PseudoVMSET_M_B1 || Opc == RISCV::PseudoVMSET_M_B16 ||
3781
3731
Opc == RISCV::PseudoVMSET_M_B2 || Opc == RISCV::PseudoVMSET_M_B32 ||
@@ -3786,14 +3736,7 @@ static bool usesAllOnesMask(SDValue MaskOp, SDValue GlueOp) {
3786
3736
// TODO: Check that the VMSET is the expected bitwidth? The pseudo has
3787
3737
// undefined behaviour if it's the wrong bitwidth, so we could choose to
3788
3738
// assume that it's all-ones? Same applies to its VL.
3789
- return MaskSetter->isMachineOpcode () &&
3790
- IsVMSet (MaskSetter.getMachineOpcode ());
3791
- }
3792
-
3793
- // Return true if we can make sure mask of N is all-ones mask.
3794
- static bool usesAllOnesMask (SDNode *N, unsigned MaskOpIdx) {
3795
- return usesAllOnesMask (N->getOperand (MaskOpIdx),
3796
- N->getOperand (N->getNumOperands () - 1 ));
3739
+ return MaskOp->isMachineOpcode () && IsVMSet (MaskOp.getMachineOpcode ());
3797
3740
}
3798
3741
3799
3742
static bool isImplicitDef (SDValue V) {
@@ -3809,17 +3752,15 @@ static bool isImplicitDef(SDValue V) {
3809
3752
}
3810
3753
3811
3754
// Optimize masked RVV pseudo instructions with a known all-ones mask to their
3812
- // corresponding "unmasked" pseudo versions. The mask we're interested in will
3813
- // take the form of a V0 physical register operand, with a glued
3814
- // register-setting instruction.
3755
+ // corresponding "unmasked" pseudo versions.
3815
3756
bool RISCVDAGToDAGISel::doPeepholeMaskedRVV (MachineSDNode *N) {
3816
3757
const RISCV::RISCVMaskedPseudoInfo *I =
3817
3758
RISCV::getMaskedPseudoInfo (N->getMachineOpcode ());
3818
3759
if (!I)
3819
3760
return false ;
3820
3761
3821
3762
unsigned MaskOpIdx = I->MaskOpIdx ;
3822
- if (!usesAllOnesMask (N, MaskOpIdx))
3763
+ if (!usesAllOnesMask (N-> getOperand ( MaskOpIdx) ))
3823
3764
return false ;
3824
3765
3825
3766
// There are two classes of pseudos in the table - compares and
@@ -3843,18 +3784,13 @@ bool RISCVDAGToDAGISel::doPeepholeMaskedRVV(MachineSDNode *N) {
3843
3784
// Skip the passthru operand at index 0 if the unmasked don't have one.
3844
3785
bool ShouldSkip = !HasPassthru && MaskedHasPassthru;
3845
3786
for (unsigned I = ShouldSkip, E = N->getNumOperands (); I != E; I++) {
3846
- // Skip the mask, and the Glue.
3787
+ // Skip the mask
3847
3788
SDValue Op = N->getOperand (I);
3848
- if (I == MaskOpIdx || Op. getValueType () == MVT::Glue )
3789
+ if (I == MaskOpIdx)
3849
3790
continue ;
3850
3791
Ops.push_back (Op);
3851
3792
}
3852
3793
3853
- // Transitively apply any node glued to our new node.
3854
- const auto *Glued = N->getGluedNode ();
3855
- if (auto *TGlued = Glued->getGluedNode ())
3856
- Ops.push_back (SDValue (TGlued, TGlued->getNumValues () - 1 ));
3857
-
3858
3794
MachineSDNode *Result =
3859
3795
CurDAG->getMachineNode (Opc, SDLoc (N), N->getVTList (), Ops);
3860
3796
@@ -3890,17 +3826,13 @@ static bool IsVMerge(SDNode *N) {
3890
3826
// The resulting policy is the effective policy the vmerge would have had,
3891
3827
// i.e. whether or not it's passthru operand was implicit-def.
3892
3828
bool RISCVDAGToDAGISel::performCombineVMergeAndVOps (SDNode *N) {
3893
- SDValue Passthru, False, True, VL, Mask, Glue ;
3829
+ SDValue Passthru, False, True, VL, Mask;
3894
3830
assert (IsVMerge (N));
3895
3831
Passthru = N->getOperand (0 );
3896
3832
False = N->getOperand (1 );
3897
3833
True = N->getOperand (2 );
3898
3834
Mask = N->getOperand (3 );
3899
3835
VL = N->getOperand (4 );
3900
- // We always have a glue node for the mask at v0.
3901
- Glue = N->getOperand (N->getNumOperands () - 1 );
3902
- assert (cast<RegisterSDNode>(Mask)->getReg () == RISCV::V0);
3903
- assert (Glue.getValueType () == MVT::Glue);
3904
3836
3905
3837
// If the EEW of True is different from vmerge's SEW, then we can't fold.
3906
3838
if (True.getSimpleValueType () != N->getSimpleValueType (0 ))
@@ -3943,12 +3875,7 @@ bool RISCVDAGToDAGISel::performCombineVMergeAndVOps(SDNode *N) {
3943
3875
if (TII->get (TrueOpc).hasUnmodeledSideEffects ())
3944
3876
return false ;
3945
3877
3946
- // The last operand of a masked instruction may be glued.
3947
- bool HasGlueOp = True->getGluedNode () != nullptr ;
3948
-
3949
- // The chain operand may exist either before the glued operands or in the last
3950
- // position.
3951
- unsigned TrueChainOpIdx = True.getNumOperands () - HasGlueOp - 1 ;
3878
+ unsigned TrueChainOpIdx = True.getNumOperands () - 1 ;
3952
3879
bool HasChainOp =
3953
3880
True.getOperand (TrueChainOpIdx).getValueType () == MVT::Other;
3954
3881
@@ -3960,15 +3887,14 @@ bool RISCVDAGToDAGISel::performCombineVMergeAndVOps(SDNode *N) {
3960
3887
LoopWorklist.push_back (False.getNode ());
3961
3888
LoopWorklist.push_back (Mask.getNode ());
3962
3889
LoopWorklist.push_back (VL.getNode ());
3963
- LoopWorklist.push_back (Glue.getNode ());
3964
3890
if (SDNode::hasPredecessorHelper (True.getNode (), Visited, LoopWorklist))
3965
3891
return false ;
3966
3892
}
3967
3893
3968
3894
// The vector policy operand may be present for masked intrinsics
3969
3895
bool HasVecPolicyOp = RISCVII::hasVecPolicyOp (TrueTSFlags);
3970
3896
unsigned TrueVLIndex =
3971
- True.getNumOperands () - HasVecPolicyOp - HasChainOp - HasGlueOp - 2 ;
3897
+ True.getNumOperands () - HasVecPolicyOp - HasChainOp - 2 ;
3972
3898
SDValue TrueVL = True.getOperand (TrueVLIndex);
3973
3899
SDValue SEW = True.getOperand (TrueVLIndex + 1 );
3974
3900
@@ -4000,7 +3926,7 @@ bool RISCVDAGToDAGISel::performCombineVMergeAndVOps(SDNode *N) {
4000
3926
if (RISCVII::elementsDependOnVL (TrueBaseMCID.TSFlags ) && (TrueVL != VL))
4001
3927
return false ;
4002
3928
if (RISCVII::elementsDependOnMask (TrueBaseMCID.TSFlags ) &&
4003
- (Mask && !usesAllOnesMask (Mask, Glue )))
3929
+ (Mask && !usesAllOnesMask (Mask)))
4004
3930
return false ;
4005
3931
4006
3932
// Make sure it doesn't raise any observable fp exceptions, since changing the
@@ -4057,9 +3983,6 @@ bool RISCVDAGToDAGISel::performCombineVMergeAndVOps(SDNode *N) {
4057
3983
if (HasChainOp)
4058
3984
Ops.push_back (True.getOperand (TrueChainOpIdx));
4059
3985
4060
- // Add the glue for the CopyToReg of mask->v0.
4061
- Ops.push_back (Glue);
4062
-
4063
3986
MachineSDNode *Result =
4064
3987
CurDAG->getMachineNode (MaskedOpc, DL, True->getVTList (), Ops);
4065
3988
Result->setFlags (True->getFlags ());
0 commit comments