Skip to content

Commit

Permalink
[AIE] fix resource off-by-one glitch
Browse files Browse the repository at this point in the history
  • Loading branch information
Martien de Jong committed Dec 9, 2024
1 parent 8018778 commit b05dcd6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
20 changes: 11 additions & 9 deletions llvm/lib/Target/AIE/AIEPostPipeliner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ void PostPipeliner::computeForward() {
const int NewEarliest = Me.Earliest + Dep.getSignedLatency();
SInfo.Earliest = std::max(SInfo.Earliest, NewEarliest);
}
Me.Slots = getSlotCounts(*SU.getInstr(), TII);
}
}

Expand Down Expand Up @@ -270,24 +271,25 @@ bool PostPipeliner::computeLoopCarriedParameters() {
/* EMPTY */;
}

// Adjust Earliest and Latest with resource requirements
// Adjust Earliest and Latest with resource requirements.
// FIXME: We do not account for negative latencies here. This can lead to
// suboptimality, but we only include true dependences, where negative
// latencies are rare.
for (int K = 0; K < NInstr; K++) {
auto &Me = Info[K];
SlotCounts ASlots;
SlotCounts ASlots(Me.Slots);
for (int A : Me.Ancestors) {
auto &SU = DAG->SUnits[A];
ASlots += getSlotCounts(*SU.getInstr(), TII);
ASlots += Info[A].Slots;
}
SlotCounts OSlots;
SlotCounts OSlots(Me.Slots);
for (int O : Me.Offspring) {
auto &SU = DAG->SUnits[O];
OSlots += getSlotCounts(*SU.getInstr(), TII);
OSlots += Info[O].Slots;
}
LLVM_DEBUG(dbgs() << "SU" << K << " : " << Info[K].Earliest << " - "
<< Info[K].Latest << " " << ASlots << " " << OSlots
<< "\n");
Me.Earliest = std::max(Me.Earliest, ASlots.max());
Me.Latest = std::min(Me.Latest, -OSlots.max());
Me.Earliest = std::max(Me.Earliest, 0 + (ASlots.max() - 1));
Me.Latest = std::min(Me.Latest, -1 - (OSlots.max() - 1));
LLVM_DEBUG(dbgs() << " -> " << Info[K].Earliest << " - "
<< Info[K].Latest << "\n");
}
Expand Down
4 changes: 4 additions & 0 deletions llvm/lib/Target/AIE/AIEPostPipeliner.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#define LLVM_LIB_TARGET_AIE_AIEPOSTPIPELINER_H

#include "AIEHazardRecognizer.h"
#include "AIESlotCounts.h"
#include "llvm/CodeGen/MachineScheduler.h"
#include "llvm/CodeGen/ResourceScoreboard.h"
#include <unordered_set>
Expand Down Expand Up @@ -64,6 +65,9 @@ class NodeInfo {
int StaticEarliest = 0;
int StaticLatest = -1;

// Slots necessary for this instruction.
SlotCounts Slots;

// Record critical path components
// The Pred/Succ that pushed my Earliest/Latest
std::optional<int> LastEarliestPusher;
Expand Down

0 comments on commit b05dcd6

Please sign in to comment.