[llvm] [RISCV][VLOPT] Allow propagation even when VL isn't VLMAX (PR #112228)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 16 08:36:18 PDT 2024
================
@@ -759,29 +781,42 @@ bool RISCVVLOptimizer::tryReduceVL(MachineInstr &OrigMI) {
MachineInstr &MI = *Worklist.pop_back_val();
LLVM_DEBUG(dbgs() << "Trying to reduce VL for " << MI << "\n");
- std::optional<Register> CommonVL;
+ const MachineOperand *CommonVL = nullptr;
bool CanReduceVL = true;
if (isVectorRegClass(MI.getOperand(0).getReg(), MRI))
CanReduceVL = checkUsers(CommonVL, MI);
if (!CanReduceVL || !CommonVL)
continue;
- if (!CommonVL->isVirtual()) {
- LLVM_DEBUG(
- dbgs() << " Abort due to new VL is not virtual register.\n");
+ assert((CommonVL->isImm() || CommonVL->getReg().isVirtual()) &&
+ "Expected VL to be an Imm or virtual Reg");
+
+ unsigned VLOpNum = RISCVII::getVLOpNum(MI.getDesc());
+ MachineOperand &VLOp = MI.getOperand(VLOpNum);
+
+ if (!RISCV::isVLKnownLE(*CommonVL, VLOp)) {
+ LLVM_DEBUG(dbgs() << " Abort due to no benefit.\n");
----------------
lukel97 wrote:
Nit, I think it would be a bit clearer if the debug message explicitly said "Abort due to CommonVL not <= VLOp" or something
https://github.com/llvm/llvm-project/pull/112228
More information about the llvm-commits
mailing list