[llvm] 7c77355 - [RISCV] Combine repeated calls to MachineFunction::getSubtarget. NFC
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 14 16:58:56 PST 2024
Author: Craig Topper
Date: 2024-01-14T16:57:33-08:00
New Revision: 7c773558ca43c03163f1df5deae7537f1f789cb5
URL: https://github.com/llvm/llvm-project/commit/7c773558ca43c03163f1df5deae7537f1f789cb5
DIFF: https://github.com/llvm/llvm-project/commit/7c773558ca43c03163f1df5deae7537f1f789cb5.diff
LOG: [RISCV] Combine repeated calls to MachineFunction::getSubtarget. NFC
Added:
Modified:
llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp b/llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
index 24f8d600f1eafc..08e83c71c82def 100644
--- a/llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
@@ -270,8 +270,9 @@ void RISCVRegisterInfo::lowerVSPILL(MachineBasicBlock::iterator II) const {
MachineBasicBlock &MBB = *II->getParent();
MachineFunction &MF = *MBB.getParent();
MachineRegisterInfo &MRI = MF.getRegInfo();
- const TargetInstrInfo *TII = MF.getSubtarget().getInstrInfo();
- const TargetRegisterInfo *TRI = MF.getSubtarget().getRegisterInfo();
+ const RISCVSubtarget &STI = MF.getSubtarget<RISCVSubtarget>();
+ const TargetInstrInfo *TII = STI.getInstrInfo();
+ const TargetRegisterInfo *TRI = STI.getRegisterInfo();
auto ZvlssegInfo = RISCV::isRVVSpillForZvlsseg(II->getOpcode());
unsigned NF = ZvlssegInfo->first;
@@ -303,7 +304,6 @@ void RISCVRegisterInfo::lowerVSPILL(MachineBasicBlock::iterator II) const {
Register VL = MRI.createVirtualRegister(&RISCV::GPRRegClass);
// Optimize for constant VLEN.
- const RISCVSubtarget &STI = MF.getSubtarget<RISCVSubtarget>();
if (STI.getRealMinVLen() == STI.getRealMaxVLen()) {
const int64_t VLENB = STI.getRealMinVLen() / 8;
int64_t Offset = VLENB * LMUL;
@@ -347,8 +347,9 @@ void RISCVRegisterInfo::lowerVRELOAD(MachineBasicBlock::iterator II) const {
MachineBasicBlock &MBB = *II->getParent();
MachineFunction &MF = *MBB.getParent();
MachineRegisterInfo &MRI = MF.getRegInfo();
- const TargetInstrInfo *TII = MF.getSubtarget().getInstrInfo();
- const TargetRegisterInfo *TRI = MF.getSubtarget().getRegisterInfo();
+ const RISCVSubtarget &STI = MF.getSubtarget<RISCVSubtarget>();
+ const TargetInstrInfo *TII = STI.getInstrInfo();
+ const TargetRegisterInfo *TRI = STI.getRegisterInfo();
auto ZvlssegInfo = RISCV::isRVVSpillForZvlsseg(II->getOpcode());
unsigned NF = ZvlssegInfo->first;
@@ -380,7 +381,6 @@ void RISCVRegisterInfo::lowerVRELOAD(MachineBasicBlock::iterator II) const {
Register VL = MRI.createVirtualRegister(&RISCV::GPRRegClass);
// Optimize for constant VLEN.
- const RISCVSubtarget &STI = MF.getSubtarget<RISCVSubtarget>();
if (STI.getRealMinVLen() == STI.getRealMaxVLen()) {
const int64_t VLENB = STI.getRealMinVLen() / 8;
int64_t Offset = VLENB * LMUL;
More information about the llvm-commits
mailing list