[llvm] 017a24e - [RISCV] Minor refactoring of some code in copyPhysReg. NFC

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 21 18:07:31 PDT 2023


Author: Craig Topper
Date: 2023-06-21T18:02:58-07:00
New Revision: 017a24eb1b2dad204bc5a8337719e72ea87c689a

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

LOG: [RISCV] Minor refactoring of some code in copyPhysReg. NFC

Move some of the vmv.v.i handling into the vmv.v.v if. This
reduces the scope of one variable.

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 e3f7d9785542e..6195f99bd271c 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
@@ -417,12 +417,13 @@ void RISCVInstrInfo::copyPhysReg(MachineBasicBlock &MBB,
 
   if (IsScalableVector) {
     bool UseVMV_V_V = false;
+    bool UseVMV_V_I = false;
     MachineBasicBlock::const_iterator DefMBBI;
-    unsigned VIOpc;
     if (isConvertibleToVMV_V_V(STI, MBB, MBBI, DefMBBI, LMul)) {
       UseVMV_V_V = true;
       // We only need to handle LMUL = 1/2/4/8 here because we only define
       // vector register classes for LMUL = 1/2/4/8.
+      unsigned VIOpc;
       switch (LMul) {
       default:
         llvm_unreachable("Impossible LMUL for vector register copy.");
@@ -443,12 +444,11 @@ void RISCVInstrInfo::copyPhysReg(MachineBasicBlock &MBB,
         VIOpc = RISCV::PseudoVMV_V_I_M8;
         break;
       }
-    }
 
-    bool UseVMV_V_I = false;
-    if (UseVMV_V_V && (DefMBBI->getOpcode() == VIOpc)) {
-      UseVMV_V_I = true;
-      Opc = VIOpc;
+      if (DefMBBI->getOpcode() == VIOpc) {
+        UseVMV_V_I = true;
+        Opc = VIOpc;
+      }
     }
 
     if (NF == 1) {


        


More information about the llvm-commits mailing list