@@ -178,6 +178,26 @@ class VSETVLIInfo {
178
178
return getSEWLMULRatio () == Other.getSEWLMULRatio ();
179
179
}
180
180
181
+ bool hasCompatibleVTYPE (const VSETVLIInfo &InstrInfo, bool Strict) const {
182
+ // Simple case, see if full VTYPE matches.
183
+ if (hasSameVTYPE (InstrInfo))
184
+ return true ;
185
+
186
+ if (Strict)
187
+ return false ;
188
+
189
+ // If this is a mask reg operation, it only cares about VLMAX.
190
+ // FIXME: Mask reg operations are probably ok if "this" VLMAX is larger
191
+ // than "InstrInfo".
192
+ // FIXME: The policy bits can probably be ignored for mask reg operations.
193
+ if (InstrInfo.MaskRegOp && hasSameVLMAX (InstrInfo) &&
194
+ TailAgnostic == InstrInfo.TailAgnostic &&
195
+ MaskAgnostic == InstrInfo.MaskAgnostic )
196
+ return true ;
197
+
198
+ return false ;
199
+ }
200
+
181
201
// Determine whether the vector instructions requirements represented by
182
202
// InstrInfo are compatible with the previous vsetvli instruction represented
183
203
// by this.
@@ -206,23 +226,15 @@ class VSETVLIInfo {
206
226
if (!hasSameAVL (InstrInfo))
207
227
return false ;
208
228
209
- // Simple case, see if full VTYPE matches.
210
- if (hasSameVTYPE (InstrInfo))
229
+ if (hasCompatibleVTYPE (InstrInfo, Strict))
211
230
return true ;
212
231
213
232
// Strict matches must ensure a full VTYPE match.
214
233
if (Strict)
215
234
return false ;
216
235
217
- // If this is a mask reg operation, it only cares about VLMAX.
218
- // FIXME: Mask reg operations are probably ok if "this" VLMAX is larger
219
- // than "InstrInfo".
220
- if (InstrInfo.MaskRegOp && hasSameVLMAX (InstrInfo) &&
221
- TailAgnostic == InstrInfo.TailAgnostic &&
222
- MaskAgnostic == InstrInfo.MaskAgnostic )
223
- return true ;
224
-
225
236
// Store instructions don't use the policy fields.
237
+ // TODO: Move into hasCompatibleVTYPE?
226
238
if (InstrInfo.StoreOp && VLMul == InstrInfo.VLMul && SEW == InstrInfo.SEW )
227
239
return true ;
228
240
@@ -564,7 +576,7 @@ bool RISCVInsertVSETVLI::needVSETVLI(const VSETVLIInfo &Require,
564
576
// VSETVLI here.
565
577
if (!CurInfo.isUnknown () && Require.hasAVLReg () &&
566
578
Require.getAVLReg ().isVirtual () && !CurInfo.hasSEWLMULRatioOnly () &&
567
- Require. hasSameVTYPE (CurInfo )) {
579
+ CurInfo. hasCompatibleVTYPE (Require, /* Strict */ false )) {
568
580
if (MachineInstr *DefMI = MRI->getVRegDef (Require.getAVLReg ())) {
569
581
if (DefMI->getOpcode () == RISCV::PseudoVSETVLI ||
570
582
DefMI->getOpcode () == RISCV::PseudoVSETVLIX0 ||
0 commit comments