@@ -691,10 +691,6 @@ inline raw_ostream &operator<<(raw_ostream &OS, const VSETVLIInfo &V) {
691
691
#endif
692
692
693
693
struct BlockData {
694
- // The VSETVLIInfo that represents the net changes to the VL/VTYPE registers
695
- // made by this block. Calculated in Phase 1.
696
- VSETVLIInfo Change;
697
-
698
694
// The VSETVLIInfo that represents the VL/VTYPE settings on exit from this
699
695
// block. Calculated in Phase 2.
700
696
VSETVLIInfo Exit;
@@ -742,9 +738,10 @@ class RISCVInsertVSETVLI : public MachineFunctionPass {
742
738
MachineBasicBlock::iterator InsertPt, DebugLoc DL,
743
739
const VSETVLIInfo &Info, const VSETVLIInfo &PrevInfo);
744
740
745
- void transferBefore (VSETVLIInfo &Info, const MachineInstr &MI);
746
- void transferAfter (VSETVLIInfo &Info, const MachineInstr &MI);
747
- bool computeVLVTYPEChanges (const MachineBasicBlock &MBB);
741
+ void transferBefore (VSETVLIInfo &Info, const MachineInstr &MI) const ;
742
+ void transferAfter (VSETVLIInfo &Info, const MachineInstr &MI) const ;
743
+ bool computeVLVTYPEChanges (const MachineBasicBlock &MBB,
744
+ VSETVLIInfo &Info) const ;
748
745
void computeIncomingVLVTYPE (const MachineBasicBlock &MBB);
749
746
void emitVSETVLIs (MachineBasicBlock &MBB);
750
747
void doLocalPostpass (MachineBasicBlock &MBB);
@@ -1006,7 +1003,8 @@ bool RISCVInsertVSETVLI::needVSETVLI(const MachineInstr &MI,
1006
1003
// Given an incoming state reaching MI, modifies that state so that it is minimally
1007
1004
// compatible with MI. The resulting state is guaranteed to be semantically legal
1008
1005
// for MI, but may not be the state requested by MI.
1009
- void RISCVInsertVSETVLI::transferBefore (VSETVLIInfo &Info, const MachineInstr &MI) {
1006
+ void RISCVInsertVSETVLI::transferBefore (VSETVLIInfo &Info,
1007
+ const MachineInstr &MI) const {
1010
1008
uint64_t TSFlags = MI.getDesc ().TSFlags ;
1011
1009
if (!RISCVII::hasSEWOp (TSFlags))
1012
1010
return ;
@@ -1063,7 +1061,8 @@ void RISCVInsertVSETVLI::transferBefore(VSETVLIInfo &Info, const MachineInstr &M
1063
1061
// Given a state with which we evaluated MI (see transferBefore above for why
1064
1062
// this might be different that the state MI requested), modify the state to
1065
1063
// reflect the changes MI might make.
1066
- void RISCVInsertVSETVLI::transferAfter (VSETVLIInfo &Info, const MachineInstr &MI) {
1064
+ void RISCVInsertVSETVLI::transferAfter (VSETVLIInfo &Info,
1065
+ const MachineInstr &MI) const {
1067
1066
if (isVectorConfigInstr (MI)) {
1068
1067
Info = getInfoForVSETVLI (MI);
1069
1068
return ;
@@ -1082,18 +1081,18 @@ void RISCVInsertVSETVLI::transferAfter(VSETVLIInfo &Info, const MachineInstr &MI
1082
1081
Info = VSETVLIInfo::getUnknown ();
1083
1082
}
1084
1083
1085
- bool RISCVInsertVSETVLI::computeVLVTYPEChanges (const MachineBasicBlock &MBB) {
1084
+ bool RISCVInsertVSETVLI::computeVLVTYPEChanges (const MachineBasicBlock &MBB,
1085
+ VSETVLIInfo &Info) const {
1086
1086
bool HadVectorOp = false ;
1087
1087
1088
- BlockData &BBInfo = BlockInfo[MBB.getNumber ()];
1089
- BBInfo.Change = BBInfo.Pred ;
1088
+ Info = BlockInfo[MBB.getNumber ()].Pred ;
1090
1089
for (const MachineInstr &MI : MBB) {
1091
- transferBefore (BBInfo. Change , MI);
1090
+ transferBefore (Info , MI);
1092
1091
1093
1092
if (isVectorConfigInstr (MI) || RISCVII::hasSEWOp (MI.getDesc ().TSFlags ))
1094
1093
HadVectorOp = true ;
1095
1094
1096
- transferAfter (BBInfo. Change , MI);
1095
+ transferAfter (Info , MI);
1097
1096
}
1098
1097
1099
1098
return HadVectorOp;
@@ -1132,8 +1131,8 @@ void RISCVInsertVSETVLI::computeIncomingVLVTYPE(const MachineBasicBlock &MBB) {
1132
1131
// compatibility checks performed a blocks output state can change based on
1133
1132
// the input state. To cache, we'd have to add logic for finding
1134
1133
// never-compatible state changes.
1135
- computeVLVTYPEChanges (MBB) ;
1136
- VSETVLIInfo TmpStatus = BBInfo. Change ;
1134
+ VSETVLIInfo TmpStatus ;
1135
+ computeVLVTYPEChanges (MBB, TmpStatus) ;
1137
1136
1138
1137
// If the new exit value matches the old exit value, we don't need to revisit
1139
1138
// any blocks.
@@ -1528,10 +1527,11 @@ bool RISCVInsertVSETVLI::runOnMachineFunction(MachineFunction &MF) {
1528
1527
1529
1528
// Phase 1 - determine how VL/VTYPE are affected by the each block.
1530
1529
for (const MachineBasicBlock &MBB : MF) {
1531
- HaveVectorOp |= computeVLVTYPEChanges (MBB);
1530
+ VSETVLIInfo TmpStatus;
1531
+ HaveVectorOp |= computeVLVTYPEChanges (MBB, TmpStatus);
1532
1532
// Initial exit state is whatever change we found in the block.
1533
1533
BlockData &BBInfo = BlockInfo[MBB.getNumber ()];
1534
- BBInfo.Exit = BBInfo. Change ;
1534
+ BBInfo.Exit = TmpStatus ;
1535
1535
LLVM_DEBUG (dbgs () << " Initial exit state of " << printMBBReference (MBB)
1536
1536
<< " is " << BBInfo.Exit << " \n " );
1537
1537
0 commit comments