@@ -69,7 +69,7 @@ class RISCVVectorPeephole : public MachineFunctionPass {
69
69
bool foldUndefPassthruVMV_V_V (MachineInstr &MI);
70
70
bool foldVMV_V_V (MachineInstr &MI);
71
71
72
- bool hasSameEEWVLMAX (const MachineInstr &User, const MachineInstr &Src) const ;
72
+ bool hasSameEEW (const MachineInstr &User, const MachineInstr &Src) const ;
73
73
bool isAllOnesMask (const MachineInstr *MaskDef) const ;
74
74
std::optional<unsigned > getConstant (const MachineOperand &VL) const ;
75
75
bool ensureDominates (const MachineOperand &Use, MachineInstr &Src) const ;
@@ -99,28 +99,17 @@ static bool isVLKnownLE(const MachineOperand &LHS, const MachineOperand &RHS) {
99
99
return LHS.getImm () <= RHS.getImm ();
100
100
}
101
101
102
- static unsigned getSEWLMULRatio (const MachineInstr &MI) {
103
- RISCVII::VLMUL LMUL = RISCVII::getLMul (MI.getDesc ().TSFlags );
104
- unsigned Log2SEW = MI.getOperand (RISCVII::getSEWOpNum (MI.getDesc ())).getImm ();
105
- return RISCVVType::getSEWLMULRatio (1 << Log2SEW, LMUL);
106
- }
107
-
108
- // / Given \p User that has an input operand with EEW=SEW, which uses an output
109
- // / operand of \p Src with an unknown EEW, return true if their EEWs match and
110
- // / they have the same VLMAX.
111
- bool RISCVVectorPeephole::hasSameEEWVLMAX (const MachineInstr &User,
112
- const MachineInstr &Src) const {
113
- if (getSEWLMULRatio (User) != getSEWLMULRatio (Src))
114
- return false ;
115
- unsigned UserLog2SEW =
102
+ // / Given \p User that has an input operand with EEW=SEW, which uses the dest
103
+ // / operand of \p Src with an unknown EEW, return true if their EEWs match.
104
+ bool RISCVVectorPeephole::hasSameEEW (const MachineInstr &User,
105
+ const MachineInstr &Src) const {
106
+ unsigned UserSEW =
116
107
User.getOperand (RISCVII::getSEWOpNum (User.getDesc ())).getImm ();
117
- unsigned SrcLog2SEW =
108
+ unsigned SrcSEW =
118
109
Src.getOperand (RISCVII::getSEWOpNum (Src.getDesc ())).getImm ();
119
- if (RISCV::getDestEEW (TII->get (RISCV::getRVVMCOpcode (Src.getOpcode ())),
120
- SrcLog2SEW) != UserLog2SEW)
121
- return false ;
122
-
123
- return true ;
110
+ unsigned SrcEEW = RISCV::getDestEEW (
111
+ TII->get (RISCV::getRVVMCOpcode (Src.getOpcode ())), SrcSEW);
112
+ return SrcEEW == UserSEW;
124
113
}
125
114
126
115
// Attempt to reduce the VL of an instruction whose sole use is feeding a
@@ -173,8 +162,8 @@ bool RISCVVectorPeephole::tryToReduceVL(MachineInstr &MI) const {
173
162
!RISCVII::hasSEWOp (Src->getDesc ().TSFlags ))
174
163
return false ;
175
164
176
- // Src needs to have the same VLMAX and EEW as MI
177
- if (!hasSameEEWVLMAX (MI, *Src))
165
+ // Src's dest needs to have the same EEW as MI's input.
166
+ if (!hasSameEEW (MI, *Src))
178
167
return false ;
179
168
180
169
bool ElementsDependOnVL = RISCVII::elementsDependOnVL (
@@ -505,8 +494,7 @@ bool RISCVVectorPeephole::foldUndefPassthruVMV_V_V(MachineInstr &MI) {
505
494
if (Src && !Src->hasUnmodeledSideEffects () &&
506
495
MRI->hasOneUse (MI.getOperand (2 ).getReg ()) &&
507
496
RISCVII::hasVLOp (Src->getDesc ().TSFlags ) &&
508
- RISCVII::hasVecPolicyOp (Src->getDesc ().TSFlags ) &&
509
- hasSameEEWVLMAX (MI, *Src)) {
497
+ RISCVII::hasVecPolicyOp (Src->getDesc ().TSFlags ) && hasSameEEW (MI, *Src)) {
510
498
const MachineOperand &MIVL = MI.getOperand (3 );
511
499
const MachineOperand &SrcVL =
512
500
Src->getOperand (RISCVII::getVLOpNum (Src->getDesc ()));
@@ -551,8 +539,8 @@ bool RISCVVectorPeephole::foldVMV_V_V(MachineInstr &MI) {
551
539
!RISCVII::hasVecPolicyOp (Src->getDesc ().TSFlags ))
552
540
return false ;
553
541
554
- // Src needs to have the same VLMAX and EEW as MI
555
- if (!hasSameEEWVLMAX (MI, *Src))
542
+ // Src's dest needs to have the same EEW as MI's input.
543
+ if (!hasSameEEW (MI, *Src))
556
544
return false ;
557
545
558
546
// Src needs to have the same passthru as VMV_V_V
0 commit comments