-
Notifications
You must be signed in to change notification settings - Fork 14.8k
[RISCV] Reduce code duplication in RISCVMoveMerge::findMatchingInst. NFCI #154451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-backend-risc-v Author: Craig Topper (topperc) ChangesFull diff: https://github.com/llvm/llvm-project/pull/154451.diff 1 Files Affected:
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 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))
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/59/builds/22903 Here is the relevant piece of the build log for the reference
|
No description provided.