@@ -1060,6 +1060,12 @@ RISCVVLOptimizer::getVLForUser(MachineOperand &UserOp) {
1060
1060
const MachineInstr &UserMI = *UserOp.getParent ();
1061
1061
const MCInstrDesc &Desc = UserMI.getDesc ();
1062
1062
1063
+ if (!RISCVII::hasVLOp (Desc.TSFlags ) || !RISCVII::hasSEWOp (Desc.TSFlags )) {
1064
+ LLVM_DEBUG (dbgs () << " Abort due to lack of VL, assume that"
1065
+ " use VLMAX\n " );
1066
+ return std::nullopt;
1067
+ }
1068
+
1063
1069
// Instructions like reductions may use a vector register as a scalar
1064
1070
// register. In this case, we should treat it like a scalar register which
1065
1071
// does not impact the decision on whether to optimize VL. But if there is
@@ -1072,11 +1078,6 @@ RISCVVLOptimizer::getVLForUser(MachineOperand &UserOp) {
1072
1078
assert (RISCV::VRRegClass.hasSubClassEq (RC) &&
1073
1079
" Expect LMUL 1 register class for vector as scalar operands!" );
1074
1080
LLVM_DEBUG (dbgs () << " Used this operand as a scalar operand\n " );
1075
- // VMV_X_S and VFMV_F_S do not have a VL operand which would cause an assert
1076
- // failure if we called getVLOpNum. Therefore, we will return 1 in this
1077
- // case, even if it could have been set to 0.
1078
- if (!RISCVII::hasVLOp (Desc.TSFlags ) || !RISCVII::hasSEWOp (Desc.TSFlags ))
1079
- return MachineOperand::CreateImm (1 );
1080
1081
1081
1082
unsigned VLOpNum = RISCVII::getVLOpNum (Desc);
1082
1083
const MachineOperand &VLOp = UserMI.getOperand (VLOpNum);
@@ -1088,12 +1089,6 @@ RISCVVLOptimizer::getVLForUser(MachineOperand &UserOp) {
1088
1089
return std::nullopt;
1089
1090
}
1090
1091
1091
- if (!RISCVII::hasVLOp (Desc.TSFlags ) || !RISCVII::hasSEWOp (Desc.TSFlags )) {
1092
- LLVM_DEBUG (dbgs () << " Abort due to lack of VL, assume that"
1093
- " use VLMAX\n " );
1094
- return std::nullopt;
1095
- }
1096
-
1097
1092
unsigned VLOpNum = RISCVII::getVLOpNum (Desc);
1098
1093
const MachineOperand &VLOp = UserMI.getOperand (VLOpNum);
1099
1094
// Looking for an immediate or a register VL that isn't X0.
0 commit comments