[llvm] [RISCV] Check dead flag on VL def op in RISCVCoalesceVSETVLI. NFC (PR #91168)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Sun May 5 23:39:23 PDT 2024


https://github.com/lukel97 created https://github.com/llvm/llvm-project/pull/91168

Because LiveVariables has been run, we no longer need to lookup the users in MachineRegisterInfo anymore and can instead just check for the dead flag.


>From 83bcfdb0fe3a48fda6325987c89f6f2ecd272873 Mon Sep 17 00:00:00 2001
From: Luke Lau <luke at igalia.com>
Date: Mon, 6 May 2024 14:35:24 +0800
Subject: [PATCH] [RISCV] Check dead flag on VL def op in RISCVCoalesceVSETVLI.
 NFC

Because LiveVariables has been run, we no longer need to lookup the users in MachineRegisterInfo anymore and can instead just check for the dead flag.
---
 llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp b/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
index 216dc78085204e..eaebdc2e54bef4 100644
--- a/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
+++ b/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
@@ -1600,9 +1600,7 @@ bool RISCVCoalesceVSETVLI::coalesceVSETVLIs(MachineBasicBlock &MBB) {
       continue;
     }
 
-    Register RegDef = MI.getOperand(0).getReg();
-    assert(RegDef == RISCV::X0 || RegDef.isVirtual());
-    if (RegDef != RISCV::X0 && !MRI->use_nodbg_empty(RegDef))
+    if (!MI.getOperand(0).isDead())
       Used.demandVL();
 
     if (NextMI) {



More information about the llvm-commits mailing list