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

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


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

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

>From b362819e8385018b542867e6cd8bfb1ff8c35b03 Mon Sep 17 00:00:00 2001
From: Craig Topper <craig.topper at sifive.com>
Date: Wed, 31 Jul 2024 16:36:04 -0700
Subject: [PATCH] [RISCV][GISel] Slightly simplify the regbank selection for
 G_LOAD/STORE. NFC

Merge the isVector early out with the previous check for isVector.
---
 .../RISCV/GISel/RISCVRegisterBankInfo.cpp     | 21 ++++++++++---------
 1 file changed, 11 insertions(+), 10 deletions(-)

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) {



More information about the llvm-commits mailing list