[llvm] [RISCV][VLOPT] Get MachineInstr from MachineOperand in getOperandInfo. NFC (PR #119838)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 13 00:48:51 PST 2024


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

IICU MI should be MO's parent, so just use MachineOperand::getParent().


>From db9a855de222817c30f0793e17797f044d236fc7 Mon Sep 17 00:00:00 2001
From: Luke Lau <luke at igalia.com>
Date: Fri, 13 Dec 2024 16:45:26 +0800
Subject: [PATCH] [RISCV][VLOPT] Get MachineInstr from MachineOperand in
 getOperandInfo. NFC

IICU MI should be MO's parent, so just use MachineOperand::getParent().
---
 llvm/lib/Target/RISCV/RISCVVLOptimizer.cpp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/llvm/lib/Target/RISCV/RISCVVLOptimizer.cpp b/llvm/lib/Target/RISCV/RISCVVLOptimizer.cpp
index dabf36480f1dcf..1e1be6818b5340 100644
--- a/llvm/lib/Target/RISCV/RISCVVLOptimizer.cpp
+++ b/llvm/lib/Target/RISCV/RISCVVLOptimizer.cpp
@@ -206,9 +206,9 @@ static bool isMaskOperand(const MachineInstr &MI, const MachineOperand &MO,
 }
 
 /// Return the OperandInfo for MO, which is an operand of MI.
-static OperandInfo getOperandInfo(const MachineInstr &MI,
-                                  const MachineOperand &MO,
+static OperandInfo getOperandInfo(const MachineOperand &MO,
                                   const MachineRegisterInfo *MRI) {
+  const MachineInstr &MI = *MO.getParent();
   const RISCVVPseudosTable::PseudoInfo *RVV =
       RISCVVPseudosTable::getPseudoInfo(MI.getOpcode());
   assert(RVV && "Could not find MI in PseudoTable");
@@ -804,8 +804,8 @@ bool RISCVVLOptimizer::checkUsers(const MachineOperand *&CommonVL,
     assert(isVectorRegClass(UserMI.getOperand(0).getReg(), MRI) &&
            "Expected DEF and USE to be vector registers");
 
-    OperandInfo ConsumerInfo = getOperandInfo(UserMI, UserOp, MRI);
-    OperandInfo ProducerInfo = getOperandInfo(MI, MI.getOperand(0), MRI);
+    OperandInfo ConsumerInfo = getOperandInfo(UserOp, MRI);
+    OperandInfo ProducerInfo = getOperandInfo(MI.getOperand(0), MRI);
     if (ConsumerInfo.isUnknown() || ProducerInfo.isUnknown() ||
         !OperandInfo::EMULAndEEWAreEqual(ConsumerInfo, ProducerInfo)) {
       LLVM_DEBUG(dbgs() << "    Abort due to incompatible or unknown "



More information about the llvm-commits mailing list