[llvm] 9b63fff - [Hexagon] Update latencies on REG_SEQUENCE/COPY based on successors.
Krzysztof Parzyszek via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 4 12:31:01 PST 2022
Author: Sumanth Gundapaneni
Date: 2022-01-04T12:30:30-08:00
New Revision: 9b63fff3db88ffa09e968a2875a812c85fa62a33
URL: https://github.com/llvm/llvm-project/commit/9b63fff3db88ffa09e968a2875a812c85fa62a33
DIFF: https://github.com/llvm/llvm-project/commit/9b63fff3db88ffa09e968a2875a812c85fa62a33.diff
LOG: [Hexagon] Update latencies on REG_SEQUENCE/COPY based on successors.
If there are multiple uses of the def of COPY/REG_SEQUENCE, set the
latency only if the latencies on all the uses are equal, otherwise set
it to default.
Added:
Modified:
llvm/lib/Target/Hexagon/HexagonSubtarget.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/Hexagon/HexagonSubtarget.cpp b/llvm/lib/Target/Hexagon/HexagonSubtarget.cpp
index 21bb1633fa79..047b2176c684 100644
--- a/llvm/lib/Target/Hexagon/HexagonSubtarget.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonSubtarget.cpp
@@ -477,19 +477,35 @@ void HexagonSubtarget::adjustSchedDependency(SUnit *Src, int SrcOpIdx,
// If it's a REG_SEQUENCE/COPY, use its destination instruction to determine
// the correct latency.
- if ((DstInst->isRegSequence() || DstInst->isCopy()) && Dst->NumSuccs == 1) {
+ // If there are multiple uses of the def of COPY/REG_SEQUENCE, set the latency
+ // only if the latencies on all the uses are equal, otherwise set it to
+ // default.
+ if ((DstInst->isRegSequence() || DstInst->isCopy())) {
Register DReg = DstInst->getOperand(0).getReg();
- MachineInstr *DDst = Dst->Succs[0].getSUnit()->getInstr();
- unsigned UseIdx = -1;
- for (unsigned OpNum = 0; OpNum < DDst->getNumOperands(); OpNum++) {
- const MachineOperand &MO = DDst->getOperand(OpNum);
- if (MO.isReg() && MO.getReg() && MO.isUse() && MO.getReg() == DReg) {
- UseIdx = OpNum;
+ int DLatency = -1;
+ for (const auto &DDep : Dst->Succs) {
+ MachineInstr *DDst = DDep.getSUnit()->getInstr();
+ unsigned UseIdx = -1;
+ for (unsigned OpNum = 0; OpNum < DDst->getNumOperands(); OpNum++) {
+ const MachineOperand &MO = DDst->getOperand(OpNum);
+ if (MO.isReg() && MO.getReg() && MO.isUse() && MO.getReg() == DReg) {
+ UseIdx = OpNum;
+ break;
+ }
+ }
+ int Latency = (InstrInfo.getOperandLatency(&InstrItins, *SrcInst, 0,
+ *DDst, UseIdx));
+ // Set DLatency for the first time.
+ DLatency = (DLatency == -1) ? Latency : DLatency;
+
+ // For multiple uses, if the Latency is
diff erent across uses, reset
+ // DLatency.
+ if (DLatency != Latency) {
+ DLatency = -1;
break;
}
}
- int DLatency = (InstrInfo.getOperandLatency(&InstrItins, *SrcInst,
- 0, *DDst, UseIdx));
+
DLatency = std::max(DLatency, 0);
Dep.setLatency((unsigned)DLatency);
}
More information about the llvm-commits
mailing list