Skip to content

Commit 595a709

Browse files
fixup! move VLOp check
1 parent 61e681c commit 595a709

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

llvm/lib/Target/RISCV/RISCVVLOptimizer.cpp

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,6 +1060,12 @@ RISCVVLOptimizer::getVLForUser(MachineOperand &UserOp) {
10601060
const MachineInstr &UserMI = *UserOp.getParent();
10611061
const MCInstrDesc &Desc = UserMI.getDesc();
10621062

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+
10631069
// Instructions like reductions may use a vector register as a scalar
10641070
// register. In this case, we should treat it like a scalar register which
10651071
// does not impact the decision on whether to optimize VL. But if there is
@@ -1072,11 +1078,6 @@ RISCVVLOptimizer::getVLForUser(MachineOperand &UserOp) {
10721078
assert(RISCV::VRRegClass.hasSubClassEq(RC) &&
10731079
"Expect LMUL 1 register class for vector as scalar operands!");
10741080
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);
10801081

10811082
unsigned VLOpNum = RISCVII::getVLOpNum(Desc);
10821083
const MachineOperand &VLOp = UserMI.getOperand(VLOpNum);
@@ -1088,12 +1089,6 @@ RISCVVLOptimizer::getVLForUser(MachineOperand &UserOp) {
10881089
return std::nullopt;
10891090
}
10901091

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-
10971092
unsigned VLOpNum = RISCVII::getVLOpNum(Desc);
10981093
const MachineOperand &VLOp = UserMI.getOperand(VLOpNum);
10991094
// Looking for an immediate or a register VL that isn't X0.

0 commit comments

Comments
 (0)