[llvm] [RISCV] Handle non uimm5 VL constants in isVLKnownLE (PR #156639)

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 3 07:31:11 PDT 2025


================
@@ -4796,8 +4796,21 @@ unsigned RISCV::getDestLog2EEW(const MCInstrDesc &Desc, unsigned Log2SEW) {
   return Scaled;
 }
 
+static std::optional<int64_t> getEffectiveImm(const MachineOperand &MO,
+                                              const MachineRegisterInfo *MRI) {
+  assert(MO.isImm() || MO.getReg().isVirtual());
+  if (MO.isImm())
+    return MO.getImm();
+  MachineInstr *Def = MRI->getVRegDef(MO.getReg());
+  if (Def->getOpcode() == RISCV::ADDI &&
+      Def->getOperand(1).getReg() == RISCV::X0)
----------------
preames wrote:

I believe you need to check operand 1 is a register; I think it can also be a FrameIndex here.  isLoadImm is nearby and gets this correct.  

https://github.com/llvm/llvm-project/pull/156639


More information about the llvm-commits mailing list