@@ -522,17 +522,17 @@ class VSETVLIInfo {
522
522
assert (hasAVLImm ());
523
523
return AVLImm;
524
524
}
525
- const MachineInstr * getAVLDefMI () const {
525
+ const MachineInstr & getAVLDefMI () const {
526
526
assert (hasAVLReg () && AVLRegDef.DefMI );
527
- return AVLRegDef.DefMI ;
527
+ return * AVLRegDef.DefMI ;
528
528
}
529
529
530
530
void setAVL (VSETVLIInfo Info) {
531
531
assert (Info.isValid ());
532
532
if (Info.isUnknown ())
533
533
setUnknown ();
534
534
else if (Info.hasAVLReg ())
535
- setAVLRegDef (Info.getAVLDefMI (), Info.getAVLReg ());
535
+ setAVLRegDef (& Info.getAVLDefMI (), Info.getAVLReg ());
536
536
else if (Info.hasAVLVLMAX ())
537
537
setAVLVLMAX ();
538
538
else if (Info.hasAVLIgnored ())
@@ -551,10 +551,8 @@ class VSETVLIInfo {
551
551
bool hasNonZeroAVL () const {
552
552
if (hasAVLImm ())
553
553
return getAVLImm () > 0 ;
554
- if (hasAVLReg ()) {
555
- const MachineInstr *MI = getAVLDefMI ();
556
- return isNonZeroLoadImmediate (*MI);
557
- }
554
+ if (hasAVLReg ())
555
+ return isNonZeroLoadImmediate (getAVLDefMI ());
558
556
if (hasAVLVLMAX ())
559
557
return true ;
560
558
if (hasAVLIgnored ())
@@ -570,7 +568,7 @@ class VSETVLIInfo {
570
568
571
569
bool hasSameAVL (const VSETVLIInfo &Other) const {
572
570
if (hasAVLReg () && Other.hasAVLReg ())
573
- return getAVLDefMI ()-> isIdenticalTo (* Other.getAVLDefMI ());
571
+ return getAVLDefMI (). isIdenticalTo (Other.getAVLDefMI ());
574
572
575
573
if (hasAVLImm () && Other.hasAVLImm ())
576
574
return getAVLImm () == Other.getAVLImm ();
@@ -984,9 +982,9 @@ static VSETVLIInfo computeInfoForInstr(const MachineInstr &MI, uint64_t TSFlags,
984
982
// register AVLs to avoid extending live ranges without being sure we can
985
983
// kill the original source reg entirely.
986
984
if (InstrInfo.hasAVLReg ()) {
987
- const MachineInstr * DefMI = InstrInfo.getAVLDefMI ();
988
- if (isVectorConfigInstr (* DefMI)) {
989
- VSETVLIInfo DefInstrInfo = getInfoForVSETVLI (* DefMI, *MRI);
985
+ const MachineInstr & DefMI = InstrInfo.getAVLDefMI ();
986
+ if (isVectorConfigInstr (DefMI)) {
987
+ VSETVLIInfo DefInstrInfo = getInfoForVSETVLI (DefMI, *MRI);
990
988
if (DefInstrInfo.hasSameVLMAX (InstrInfo) &&
991
989
(DefInstrInfo.hasAVLImm () || DefInstrInfo.hasAVLVLMAX ()))
992
990
InstrInfo.setAVL (DefInstrInfo);
@@ -1024,9 +1022,9 @@ void RISCVInsertVSETVLI::insertVSETVLI(MachineBasicBlock &MBB,
1024
1022
// it has the same VLMAX we want and the last VL/VTYPE we observed is the
1025
1023
// same, we can use the X0, X0 form.
1026
1024
if (Info.hasSameVLMAX (PrevInfo) && Info.hasAVLReg ()) {
1027
- const MachineInstr * DefMI = Info.getAVLDefMI ();
1028
- if (isVectorConfigInstr (* DefMI)) {
1029
- VSETVLIInfo DefInfo = getInfoForVSETVLI (* DefMI, *MRI);
1025
+ const MachineInstr & DefMI = Info.getAVLDefMI ();
1026
+ if (isVectorConfigInstr (DefMI)) {
1027
+ VSETVLIInfo DefInfo = getInfoForVSETVLI (DefMI, *MRI);
1030
1028
if (DefInfo.hasSameAVL (PrevInfo) && DefInfo.hasSameVLMAX (PrevInfo)) {
1031
1029
BuildMI (MBB, InsertPt, DL, TII->get (RISCV::PseudoVSETVLIX0))
1032
1030
.addReg (RISCV::X0, RegState::Define | RegState::Dead)
@@ -1142,9 +1140,9 @@ bool RISCVInsertVSETVLI::needVSETVLI(const MachineInstr &MI,
1142
1140
// and the last VL/VTYPE we observed is the same, we don't need a
1143
1141
// VSETVLI here.
1144
1142
if (Require.hasAVLReg () && CurInfo.hasCompatibleVTYPE (Used, Require)) {
1145
- const MachineInstr * DefMI = Require.getAVLDefMI ();
1146
- if (DefMI && isVectorConfigInstr (* DefMI)) {
1147
- VSETVLIInfo DefInfo = getInfoForVSETVLI (* DefMI, *MRI);
1143
+ const MachineInstr & DefMI = Require.getAVLDefMI ();
1144
+ if (isVectorConfigInstr (DefMI)) {
1145
+ VSETVLIInfo DefInfo = getInfoForVSETVLI (DefMI, *MRI);
1148
1146
if (DefInfo.hasSameAVL (CurInfo) && DefInfo.hasSameVLMAX (CurInfo))
1149
1147
return false ;
1150
1148
}
@@ -1332,7 +1330,7 @@ bool RISCVInsertVSETVLI::needVSETVLIPHI(const VSETVLIInfo &Require,
1332
1330
return true ;
1333
1331
1334
1332
// We need the AVL to be produce by a PHI node in this basic block.
1335
- const MachineInstr *PHI = Require.getAVLDefMI ();
1333
+ const MachineInstr *PHI = & Require.getAVLDefMI ();
1336
1334
if (PHI->getOpcode () != RISCV::PHI || PHI->getParent () != &MBB)
1337
1335
return true ;
1338
1336
@@ -1503,7 +1501,7 @@ void RISCVInsertVSETVLI::doPRE(MachineBasicBlock &MBB) {
1503
1501
// we need to prove the value is available at the point we're going
1504
1502
// to insert the vsetvli at.
1505
1503
if (AvailableInfo.hasAVLReg ()) {
1506
- const MachineInstr *AVLDefMI = AvailableInfo.getAVLDefMI ();
1504
+ const MachineInstr *AVLDefMI = & AvailableInfo.getAVLDefMI ();
1507
1505
// This is an inline dominance check which covers the case of
1508
1506
// UnavailablePred being the preheader of a loop.
1509
1507
if (AVLDefMI->getParent () != UnavailablePred)
0 commit comments