@@ -1040,9 +1040,23 @@ bool RISCVInsertVSETVLI::needVSETVLI(const MachineInstr &MI,
1040
1040
return true ;
1041
1041
}
1042
1042
1043
+ // If we don't use LMUL or the SEW/LMUL ratio, then adjust LMUL so that we
1044
+ // maintain the SEW/LMUL ratio. This allows us to eliminate VL toggles in more
1045
+ // places.
1043
1046
static VSETVLIInfo adjustIncoming (VSETVLIInfo PrevInfo, VSETVLIInfo NewInfo,
1044
- DemandedFields &Demanded,
1045
- const MachineRegisterInfo *MRI);
1047
+ DemandedFields &Demanded) {
1048
+ VSETVLIInfo Info = NewInfo;
1049
+
1050
+ if (!Demanded.LMUL && !Demanded.SEWLMULRatio && PrevInfo.isValid () &&
1051
+ !PrevInfo.isUnknown ()) {
1052
+ if (auto NewVLMul = RISCVVType::getSameRatioLMUL (
1053
+ PrevInfo.getSEW (), PrevInfo.getVLMUL (), Info.getSEW ()))
1054
+ Info.setVLMul (*NewVLMul);
1055
+ Demanded.LMUL = true ;
1056
+ }
1057
+
1058
+ return Info;
1059
+ }
1046
1060
1047
1061
// Given an incoming state reaching MI, minimally modifies that state so that it
1048
1062
// is compatible with MI. The resulting state is guaranteed to be semantically
@@ -1063,8 +1077,7 @@ void RISCVInsertVSETVLI::transferBefore(VSETVLIInfo &Info,
1063
1077
Info = NewInfo;
1064
1078
1065
1079
DemandedFields Demanded = getDemanded (MI, MRI, ST);
1066
- const VSETVLIInfo IncomingInfo =
1067
- adjustIncoming (PrevInfo, NewInfo, Demanded, MRI);
1080
+ const VSETVLIInfo IncomingInfo = adjustIncoming (PrevInfo, NewInfo, Demanded);
1068
1081
1069
1082
// If MI only demands that VL has the same zeroness, we only need to set the
1070
1083
// AVL if the zeroness differs. This removes a vsetvli entirely if the types
@@ -1098,25 +1111,6 @@ void RISCVInsertVSETVLI::transferBefore(VSETVLIInfo &Info,
1098
1111
}
1099
1112
}
1100
1113
1101
- static VSETVLIInfo adjustIncoming (VSETVLIInfo PrevInfo, VSETVLIInfo NewInfo,
1102
- DemandedFields &Demanded,
1103
- const MachineRegisterInfo *MRI) {
1104
- VSETVLIInfo Info = NewInfo;
1105
-
1106
- // If we don't use LMUL or the SEW/LMUL ratio, then adjust LMUL so that we
1107
- // maintain the SEW/LMUL ratio. This allows us to eliminate VL toggles in more
1108
- // places.
1109
- if (!Demanded.LMUL && !Demanded.SEWLMULRatio && PrevInfo.isValid () &&
1110
- !PrevInfo.isUnknown ()) {
1111
- if (auto NewVLMul = RISCVVType::getSameRatioLMUL (
1112
- PrevInfo.getSEW (), PrevInfo.getVLMUL (), Info.getSEW ()))
1113
- Info.setVLMul (*NewVLMul);
1114
- Demanded.LMUL = true ;
1115
- }
1116
-
1117
- return Info;
1118
- }
1119
-
1120
1114
// Given a state with which we evaluated MI (see transferBefore above for why
1121
1115
// this might be different that the state MI requested), modify the state to
1122
1116
// reflect the changes MI might make.
0 commit comments