[llvm] [RISCV][GISel] Slightly simplify the regbank selection for G_LOAD/STORE. NFC (PR #101431)

via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 31 16:37:44 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-risc-v

Author: Craig Topper (topperc)

<details>
<summary>Changes</summary>

Merge the isVector early out with the previous check for isVector.

---
Full diff: https://github.com/llvm/llvm-project/pull/101431.diff


1 Files Affected:

- (modified) llvm/lib/Target/RISCV/GISel/RISCVRegisterBankInfo.cpp (+11-10) 


``````````diff
diff --git a/llvm/lib/Target/RISCV/GISel/RISCVRegisterBankInfo.cpp b/llvm/lib/Target/RISCV/GISel/RISCVRegisterBankInfo.cpp
index 2b1df0cd4670a..5369be24f0e7c 100644
--- a/llvm/lib/Target/RISCV/GISel/RISCVRegisterBankInfo.cpp
+++ b/llvm/lib/Target/RISCV/GISel/RISCVRegisterBankInfo.cpp
@@ -311,15 +311,16 @@ RISCVRegisterBankInfo::getInstrMapping(const MachineInstr &MI) const {
   case TargetOpcode::G_LOAD: {
     LLT Ty = MRI.getType(MI.getOperand(0).getReg());
     TypeSize Size = Ty.getSizeInBits();
-    if (Ty.isVector())
-      OpdsMapping[0] = getVRBValueMapping(Size.getKnownMinValue());
-    else
-      OpdsMapping[0] = GPRValueMapping;
 
     OpdsMapping[1] = GPRValueMapping;
 
-    if (Ty.isVector())
+    if (Ty.isVector()) {
+      OpdsMapping[0] = getVRBValueMapping(Size.getKnownMinValue());
       break;
+    }
+
+    OpdsMapping[0] = GPRValueMapping;
+
     // Use FPR64 for s64 loads on rv32.
     if (GPRSize == 32 && Size.getFixedValue() == 64) {
       assert(MF.getSubtarget<RISCVSubtarget>().hasStdExtD());
@@ -342,15 +343,15 @@ RISCVRegisterBankInfo::getInstrMapping(const MachineInstr &MI) const {
   case TargetOpcode::G_STORE: {
     LLT Ty = MRI.getType(MI.getOperand(0).getReg());
     TypeSize Size = Ty.getSizeInBits();
-    if (Ty.isVector())
-      OpdsMapping[0] = getVRBValueMapping(Size.getKnownMinValue());
-    else
-      OpdsMapping[0] = GPRValueMapping;
 
     OpdsMapping[1] = GPRValueMapping;
 
-    if (Ty.isVector())
+    if (Ty.isVector()) {
+      OpdsMapping[0] = getVRBValueMapping(Size.getKnownMinValue());
       break;
+    }
+
+    OpdsMapping[0] = GPRValueMapping;
 
     // Use FPR64 for s64 stores on rv32.
     if (GPRSize == 32 && Size.getFixedValue() == 64) {

``````````

</details>


https://github.com/llvm/llvm-project/pull/101431


More information about the llvm-commits mailing list