[llvm] d145dc1 - [RISCV] Reduce code duplication in RISCVMoveMerge::findMatchingInst. NFCI (#154451)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 19 21:09:01 PDT 2025
Author: Craig Topper
Date: 2025-08-19T21:08:57-07:00
New Revision: d145dc10b63f54eca45812fa08528aa495e3dcdb
URL: https://github.com/llvm/llvm-project/commit/d145dc10b63f54eca45812fa08528aa495e3dcdb
DIFF: https://github.com/llvm/llvm-project/commit/d145dc10b63f54eca45812fa08528aa495e3dcdb.diff
LOG: [RISCV] Reduce code duplication in RISCVMoveMerge::findMatchingInst. NFCI (#154451)
Added:
Modified:
llvm/lib/Target/RISCV/RISCVMoveMerger.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/RISCVMoveMerger.cpp b/llvm/lib/Target/RISCV/RISCVMoveMerger.cpp
index d234dcf109d6a..ae311db443bf7 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
diff erent.
- if ((RegPair.Destination->getReg() == DestReg))
+ bool IsCandidate = MoveFromSToA ? isCandidateToMergeMVA01S(*SecondPair)
+ : isCandidateToMergeMVSA01(*SecondPair);
+ if (IsCandidate) {
+ // Second destination must be
diff erent.
+ 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
diff erent.
+ 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))
More information about the llvm-commits
mailing list