[llvm] [RISCV][VLOPT] Add support for checkUsers when UserMI is a Single-Width Integer Reduction (PR #120345)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 2 17:36:16 PST 2025
================
@@ -963,46 +1031,58 @@ bool RISCVVLOptimizer::checkUsers(const MachineOperand *&CommonVL,
break;
}
- const MCInstrDesc &Desc = UserMI.getDesc();
- if (!RISCVII::hasVLOp(Desc.TSFlags) || !RISCVII::hasSEWOp(Desc.TSFlags)) {
- LLVM_DEBUG(dbgs() << " Abort due to lack of VL or SEW, assume that"
- " use VLMAX\n");
+ auto VLOp = getVLForUser(UserOp);
+ if (!VLOp) {
CanReduceVL = false;
break;
}
- unsigned VLOpNum = RISCVII::getVLOpNum(Desc);
- const MachineOperand &VLOp = UserMI.getOperand(VLOpNum);
-
- // Looking for an immediate or a register VL that isn't X0.
- assert((!VLOp.isReg() || VLOp.getReg() != RISCV::X0) &&
- "Did not expect X0 VL");
-
// Use the largest VL among all the users. If we cannot determine this
// statically, then we cannot optimize the VL.
- if (!CommonVL || RISCV::isVLKnownLE(*CommonVL, VLOp)) {
- CommonVL = &VLOp;
+ if (!CommonVL || RISCV::isVLKnownLE(*CommonVL, *VLOp)) {
+ CommonVL.emplace(*VLOp);
----------------
topperc wrote:
Why do we need to use `emplace` here? Does `CommonVl = *VLOp` not work?
https://github.com/llvm/llvm-project/pull/120345
More information about the llvm-commits
mailing list