aboutsummaryrefslogtreecommitdiff
path: root/llvm
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@sifive.com>2025-08-19 21:08:57 -0700
committerGitHub <noreply@github.com>2025-08-19 21:08:57 -0700
commitd145dc10b63f54eca45812fa08528aa495e3dcdb (patch)
tree04b16cc1b06bed93a523427d490cb884232ebcc8 /llvm
parent2db239acd1e4cb61e8c5c55dcc4b08c7d64919b6 (diff)
downloadllvm-d145dc10b63f54eca45812fa08528aa495e3dcdb.zip
llvm-d145dc10b63f54eca45812fa08528aa495e3dcdb.tar.gz
llvm-d145dc10b63f54eca45812fa08528aa495e3dcdb.tar.bz2
[RISCV] Reduce code duplication in RISCVMoveMerge::findMatchingInst. NFCI (#154451)
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/Target/RISCV/RISCVMoveMerger.cpp25
1 files changed, 10 insertions, 15 deletions
diff --git a/llvm/lib/Target/RISCV/RISCVMoveMerger.cpp b/llvm/lib/Target/RISCV/RISCVMoveMerger.cpp
index d234dcf..ae311db 100644
--- a/llvm/lib/Target/RISCV/RISCVMoveMerger.cpp
+++ b/llvm/lib/Target/RISCV/RISCVMoveMerger.cpp
@@ -176,25 +176,20 @@ RISCVMoveMerge::findMatchingInst(MachineBasicBlock::iterator &MBBI,
Register SourceReg = SecondPair->Source->getReg();
Register DestReg = SecondPair->Destination->getReg();
- if (MoveFromSToA && isCandidateToMergeMVA01S(*SecondPair)) {
- // If register pair is valid and destination registers are different.
- if ((RegPair.Destination->getReg() == DestReg))
+ bool IsCandidate = MoveFromSToA ? isCandidateToMergeMVA01S(*SecondPair)
+ : isCandidateToMergeMVSA01(*SecondPair);
+ if (IsCandidate) {
+ // Second destination must be different.
+ if (RegPair.Destination->getReg() == DestReg)
return E;
- // If paired destination register was modified or used, the source reg
- // was modified, there is no possibility of finding matching
- // instruction so exit early.
- if (!ModifiedRegUnits.available(DestReg) ||
- !UsedRegUnits.available(DestReg) ||
- !ModifiedRegUnits.available(SourceReg))
- return E;
-
- return I;
- } else if (!MoveFromSToA && isCandidateToMergeMVSA01(*SecondPair)) {
- if ((RegPair.Source->getReg() == SourceReg) ||
- (RegPair.Destination->getReg() == DestReg))
+ // For AtoS the source must also be different.
+ if (!MoveFromSToA && RegPair.Source->getReg() == SourceReg)
return E;
+ // If paired destination register was modified or used, the source reg
+ // was modified, there is no possibility of finding matching
+ // instruction so exit early.
if (!ModifiedRegUnits.available(DestReg) ||
!UsedRegUnits.available(DestReg) ||
!ModifiedRegUnits.available(SourceReg))