[llvm] 2c8e7b2 - [RISCV] Pull out repeated calls to getOperand. NFC
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 16 00:53:53 PST 2022
Author: Craig Topper
Date: 2022-12-16T00:50:07-08:00
New Revision: 2c8e7b2257e52eb713f623a756bb0e351ff99ea9
URL: https://github.com/llvm/llvm-project/commit/2c8e7b2257e52eb713f623a756bb0e351ff99ea9
DIFF: https://github.com/llvm/llvm-project/commit/2c8e7b2257e52eb713f623a756bb0e351ff99ea9.diff
LOG: [RISCV] Pull out repeated calls to getOperand. NFC
Remove else after return.
Added:
Modified:
llvm/lib/Target/RISCV/RISCVMergeBaseOffset.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/RISCVMergeBaseOffset.cpp b/llvm/lib/Target/RISCV/RISCVMergeBaseOffset.cpp
index a57635abb7e0..da1ada12975f 100644
--- a/llvm/lib/Target/RISCV/RISCVMergeBaseOffset.cpp
+++ b/llvm/lib/Target/RISCV/RISCVMergeBaseOffset.cpp
@@ -89,32 +89,38 @@ INITIALIZE_PASS(RISCVMergeBaseOffsetOpt, DEBUG_TYPE,
bool RISCVMergeBaseOffsetOpt::detectFoldable(MachineInstr &Hi,
MachineInstr *&Lo) {
if (Hi.getOpcode() == RISCV::LUI) {
- if (Hi.getOperand(1).getTargetFlags() != RISCVII::MO_HI ||
- !Hi.getOperand(1).isGlobal() || Hi.getOperand(1).getOffset() != 0 ||
- !MRI->hasOneUse(Hi.getOperand(0).getReg()))
- return false;
Register HiDestReg = Hi.getOperand(0).getReg();
+ const MachineOperand &HiOp1 = Hi.getOperand(1);
+ if (HiOp1.getTargetFlags() != RISCVII::MO_HI || !HiOp1.isGlobal() ||
+ HiOp1.getOffset() != 0 || !MRI->hasOneUse(HiDestReg))
+ return false;
Lo = &*MRI->use_instr_begin(HiDestReg);
- if (Lo->getOpcode() != RISCV::ADDI ||
- Lo->getOperand(2).getTargetFlags() != RISCVII::MO_LO ||
- !Lo->getOperand(2).isGlobal() || Lo->getOperand(2).getOffset() != 0)
+ if (Lo->getOpcode() != RISCV::ADDI)
return false;
- return true;
- } else if (Hi.getOpcode() == RISCV::AUIPC) {
- if (Hi.getOperand(1).getTargetFlags() != RISCVII::MO_PCREL_HI ||
- !Hi.getOperand(1).isGlobal() || Hi.getOperand(1).getOffset() != 0 ||
- !MRI->hasOneUse(Hi.getOperand(0).getReg()))
+ const MachineOperand &LoOp2 = Lo->getOperand(2);
+ if (LoOp2.getTargetFlags() != RISCVII::MO_LO || !LoOp2.isGlobal() ||
+ LoOp2.getOffset() != 0)
return false;
+ return true;
+ }
+
+ if (Hi.getOpcode() == RISCV::AUIPC) {
Register HiDestReg = Hi.getOperand(0).getReg();
+ const MachineOperand &HiOp1 = Hi.getOperand(1);
+ if (HiOp1.getTargetFlags() != RISCVII::MO_PCREL_HI || !HiOp1.isGlobal() ||
+ HiOp1.getOffset() != 0 || !MRI->hasOneUse(HiDestReg))
+ return false;
Lo = &*MRI->use_instr_begin(HiDestReg);
- if (Lo->getOpcode() != RISCV::ADDI ||
- Lo->getOperand(2).getTargetFlags() != RISCVII::MO_PCREL_LO ||
- Lo->getOperand(2).getType() != MachineOperand::MO_MCSymbol)
+ if (Lo->getOpcode() != RISCV::ADDI)
+ return false;
+ const MachineOperand &LoOp2 = Lo->getOperand(2);
+ if (LoOp2.getTargetFlags() != RISCVII::MO_PCREL_LO ||
+ LoOp2.getType() != MachineOperand::MO_MCSymbol)
return false;
return true;
- } else {
- return false;
}
+
+ return false;
}
// Update the offset in Hi and Lo instructions.
More information about the llvm-commits
mailing list