[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:20 PDT 2024
================
@@ -713,16 +736,15 @@ bool RISCVVLOptimizer::checkUsers(std::optional<Register> &CommonVL,
unsigned VLOpNum = RISCVII::getVLOpNum(Desc);
const MachineOperand &VLOp = UserMI.getOperand(VLOpNum);
- // Looking for a register VL that isn't X0.
- if (!VLOp.isReg() || VLOp.getReg() == RISCV::X0) {
- LLVM_DEBUG(dbgs() << " Abort due to user uses X0 as VL.\n");
- CanReduceVL = false;
- break;
- }
+
+ // Looking for an immediate or a register VL that isn't X0.
+ assert(!VLOp.isReg() ||
+ VLOp.getReg() != RISCV::X0 && "Did not expect X0 VL");
if (!CommonVL) {
- CommonVL = VLOp.getReg();
- } else if (*CommonVL != VLOp.getReg()) {
+ CommonVL = &VLOp;
+ LLVM_DEBUG(dbgs() << " User VL is: " << VLOp << "\n");
+ } else if (!CommonVL->isIdenticalTo(VLOp)) {
----------------
lukel97 wrote:
Not related to this PR, but this requires all users to have the same VL. One possibility for another PR is to relax this and get the largest VL amongst all users
https://github.com/llvm/llvm-project/pull/112228
More information about the llvm-commits
mailing list