@@ -338,13 +338,12 @@ static bool areCompatibleVTYPEs(uint64_t CurVType, uint64_t NewVType,
338
338
339
339
// / Return the fields and properties demanded by the provided instruction.
340
340
DemandedFields getDemanded (const MachineInstr &MI,
341
- const MachineRegisterInfo *MRI) {
341
+ const MachineRegisterInfo *MRI,
342
+ const RISCVSubtarget *ST) {
342
343
// Warning: This function has to work on both the lowered (i.e. post
343
344
// emitVSETVLIs) and pre-lowering forms. The main implication of this is
344
345
// that it can't use the value of a SEW, VL, or Policy operand as they might
345
346
// be stale after lowering.
346
- bool HasVInstructionsF64 =
347
- MI.getMF ()->getSubtarget <RISCVSubtarget>().hasVInstructionsF64 ();
348
347
349
348
// Most instructions don't use any of these subfeilds.
350
349
DemandedFields Res;
@@ -403,7 +402,7 @@ DemandedFields getDemanded(const MachineInstr &MI,
403
402
// tail lanes to either be the original value or -1. We are writing
404
403
// unknown bits to the lanes here.
405
404
if (hasUndefinedMergeOp (MI, *MRI)) {
406
- if (isFloatScalarMoveOrScalarSplatInstr (MI) && !HasVInstructionsF64 )
405
+ if (isFloatScalarMoveOrScalarSplatInstr (MI) && !ST-> hasVInstructionsF64 () )
407
406
Res.SEW = DemandedFields::SEWGreaterThanOrEqualAndLessThan64;
408
407
else
409
408
Res.SEW = DemandedFields::SEWGreaterThanOrEqual;
@@ -720,6 +719,7 @@ struct BlockData {
720
719
};
721
720
722
721
class RISCVInsertVSETVLI : public MachineFunctionPass {
722
+ const RISCVSubtarget *ST;
723
723
const TargetInstrInfo *TII;
724
724
MachineRegisterInfo *MRI;
725
725
@@ -958,9 +958,7 @@ bool RISCVInsertVSETVLI::needVSETVLI(const MachineInstr &MI,
958
958
if (!CurInfo.isValid () || CurInfo.isUnknown () || CurInfo.hasSEWLMULRatioOnly ())
959
959
return true ;
960
960
961
- DemandedFields Used = getDemanded (MI, MRI);
962
- bool HasVInstructionsF64 =
963
- MI.getMF ()->getSubtarget <RISCVSubtarget>().hasVInstructionsF64 ();
961
+ DemandedFields Used = getDemanded (MI, MRI, ST);
964
962
965
963
// A slidedown/slideup with an *undefined* merge op can freely clobber
966
964
// elements not copied from the source vector (e.g. masked off, tail, or
@@ -988,7 +986,7 @@ bool RISCVInsertVSETVLI::needVSETVLI(const MachineInstr &MI,
988
986
Used.LMUL = false ;
989
987
Used.SEWLMULRatio = false ;
990
988
Used.VLAny = false ;
991
- if (isFloatScalarMoveOrScalarSplatInstr (MI) && !HasVInstructionsF64 )
989
+ if (isFloatScalarMoveOrScalarSplatInstr (MI) && !ST-> hasVInstructionsF64 () )
992
990
Used.SEW = DemandedFields::SEWGreaterThanOrEqualAndLessThan64;
993
991
else
994
992
Used.SEW = DemandedFields::SEWGreaterThanOrEqual;
@@ -1329,9 +1327,6 @@ static bool willVLBeAVL(const VSETVLIInfo &Info, const RISCVSubtarget &ST) {
1329
1327
// / this is geared to catch the common case of a fixed length vsetvl in a single
1330
1328
// / block loop when it could execute once in the preheader instead.
1331
1329
void RISCVInsertVSETVLI::doPRE (MachineBasicBlock &MBB) {
1332
- const MachineFunction &MF = *MBB.getParent ();
1333
- const RISCVSubtarget &ST = MF.getSubtarget <RISCVSubtarget>();
1334
-
1335
1330
if (!BlockInfo[MBB.getNumber ()].Pred .isUnknown ())
1336
1331
return ;
1337
1332
@@ -1360,7 +1355,7 @@ void RISCVInsertVSETVLI::doPRE(MachineBasicBlock &MBB) {
1360
1355
return ;
1361
1356
1362
1357
// If VL can be less than AVL, then we can't reduce the frequency of exec.
1363
- if (!willVLBeAVL (AvailableInfo, ST))
1358
+ if (!willVLBeAVL (AvailableInfo, * ST))
1364
1359
return ;
1365
1360
1366
1361
// Model the effect of changing the input state of the block MBB to
@@ -1476,7 +1471,7 @@ void RISCVInsertVSETVLI::doLocalPostpass(MachineBasicBlock &MBB) {
1476
1471
for (MachineInstr &MI : make_range (MBB.rbegin (), MBB.rend ())) {
1477
1472
1478
1473
if (!isVectorConfigInstr (MI)) {
1479
- doUnion (Used, getDemanded (MI, MRI));
1474
+ doUnion (Used, getDemanded (MI, MRI, ST ));
1480
1475
continue ;
1481
1476
}
1482
1477
@@ -1506,7 +1501,7 @@ void RISCVInsertVSETVLI::doLocalPostpass(MachineBasicBlock &MBB) {
1506
1501
}
1507
1502
}
1508
1503
NextMI = &MI;
1509
- Used = getDemanded (MI, MRI);
1504
+ Used = getDemanded (MI, MRI, ST );
1510
1505
}
1511
1506
1512
1507
for (auto *MI : ToDelete)
@@ -1529,13 +1524,13 @@ void RISCVInsertVSETVLI::insertReadVL(MachineBasicBlock &MBB) {
1529
1524
1530
1525
bool RISCVInsertVSETVLI::runOnMachineFunction (MachineFunction &MF) {
1531
1526
// Skip if the vector extension is not enabled.
1532
- const RISCVSubtarget & ST = MF.getSubtarget <RISCVSubtarget>();
1533
- if (!ST. hasVInstructions ())
1527
+ ST = & MF.getSubtarget <RISCVSubtarget>();
1528
+ if (!ST-> hasVInstructions ())
1534
1529
return false ;
1535
1530
1536
1531
LLVM_DEBUG (dbgs () << " Entering InsertVSETVLI for " << MF.getName () << " \n " );
1537
1532
1538
- TII = ST. getInstrInfo ();
1533
+ TII = ST-> getInstrInfo ();
1539
1534
MRI = &MF.getRegInfo ();
1540
1535
1541
1536
assert (BlockInfo.empty () && " Expect empty block infos" );
0 commit comments