[llvm] dbc3df1 - [RISCV] Remove unnecessary call to MachineFunction::getSubtarget. NFC

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 16 15:39:44 PDT 2024


Author: Craig Topper
Date: 2024-07-16T15:39:20-07:00
New Revision: dbc3df17180782006be0ad6e43d3da81d98c2d4d

URL: https://github.com/llvm/llvm-project/commit/dbc3df17180782006be0ad6e43d3da81d98c2d4d
DIFF: https://github.com/llvm/llvm-project/commit/dbc3df17180782006be0ad6e43d3da81d98c2d4d.diff

LOG: [RISCV] Remove unnecessary call to MachineFunction::getSubtarget. NFC

RISCVInstrInfo already caches a reference to the subtarget object
that owns it. We can use that.

Added: 
    

Modified: 
    llvm/lib/Target/RISCV/RISCVInstrInfo.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp b/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
index 5e1b5284751f4..ba3b4bd701d63 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
@@ -1474,10 +1474,8 @@ unsigned RISCVInstrInfo::getInstSizeInBytes(const MachineInstr &MI) const {
 
   if (!MI.memoperands_empty()) {
     MachineMemOperand *MMO = *(MI.memoperands_begin());
-    const MachineFunction &MF = *MI.getParent()->getParent();
-    const auto &ST = MF.getSubtarget<RISCVSubtarget>();
-    if (ST.hasStdExtZihintntl() && MMO->isNonTemporal()) {
-      if (ST.hasStdExtCOrZca() && ST.enableRVCHintInstrs()) {
+    if (STI.hasStdExtZihintntl() && MMO->isNonTemporal()) {
+      if (STI.hasStdExtCOrZca() && STI.enableRVCHintInstrs()) {
         if (isCompressibleInst(MI, STI))
           return 4; // c.ntl.all + c.load/c.store
         return 6;   // c.ntl.all + load/store


        


More information about the llvm-commits mailing list