[llvm] [RISCV] Eliminate dead li after emitting VSETVLIs (PR #65934)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 13 04:19:01 PST 2023
================
@@ -1262,9 +1262,17 @@ void RISCVInsertVSETVLI::emitVSETVLIs(MachineBasicBlock &MBB) {
if (RISCVII::hasVLOp(TSFlags)) {
MachineOperand &VLOp = MI.getOperand(getVLOpNum(MI));
if (VLOp.isReg()) {
+ Register Reg = VLOp.getReg();
+ MachineInstr *VLOpDef = MRI->getVRegDef(Reg);
+
// Erase the AVL operand from the instruction.
VLOp.setReg(RISCV::NoRegister);
VLOp.setIsKill(false);
+
+ // If the old VLOp was only used by MI, it's dead.
----------------
lukel97 wrote:
Maybe just a clarification on why we're specifically checking for ADDI
```suggestion
// If the AVL was an immediate > 31, then it would have been emitted as an ADDI. However, the ADDI might not have been used in the vsetvli, or a vsetvli might not have been emitted, so it may be dead now.
```
https://github.com/llvm/llvm-project/pull/65934
More information about the llvm-commits
mailing list