Skip to content
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

Interleave loop pre-header with SWP prologue #236

Open
wants to merge 8 commits into
base: aie-public
Choose a base branch
from
22 changes: 2 additions & 20 deletions llvm/lib/Target/AIE/AIEBasePipelinerLoopInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@

#define DEBUG_TYPE "aie-pipeliner"
namespace llvm {
cl::opt<int> LoopMinTripCount(
"aie-loop-min-tripcount",
cl::desc("Minimum number of loop iterations (warning: applies to all loop"
" pipelining candidates)"),
cl::init(-1), cl::Hidden);
cl::opt<bool> TrackRegPressure(
"aie-pipeliner-track-regpressure",
cl::desc("Refuse SWP schedules likely to run into register spills"),
Expand Down Expand Up @@ -69,13 +64,7 @@ AIEBasePipelinerLoopInfo::AIEBasePipelinerLoopInfo(MachineInstr *EndLoop,
AIELoopUtils::getMinTripCount(*LoopBlock);
if (ParsedMinTripCount) {
MinTripCount = *ParsedMinTripCount;
LLVM_DEBUG(dbgs() << "PLI: MinTripCount from pragma = " << MinTripCount
<< "\n");
}

if (LoopMinTripCount > MinTripCount) {
MinTripCount = LoopMinTripCount;
LLVM_DEBUG(dbgs() << "PLI: MinTripCount from CL option = " << MinTripCount
LLVM_DEBUG(dbgs() << "PLI: MinTripCount from pragma/CL = " << MinTripCount
<< "\n");
}
}
Expand Down Expand Up @@ -682,18 +671,11 @@ class ZeroOverheadLoop : public AIEBasePipelinerLoopInfo {
};

ZeroOverheadLoop::Assessment ZeroOverheadLoop::accept(MachineInstr *EndLoop) {
// We are using LoopMinTripCount below just for testing purposes.
// For MIR test cases without IR, we can't encode loop-related metadata.
if (!MinTripCount && LoopMinTripCount <= 0) {
if (!MinTripCount) {
LLVM_DEBUG(dbgs() << "Unbounded loop detected!\n");
return Assessment::UnboundedLoop;
}

// Overwrite MinTripCount.
if (LoopMinTripCount > 0) {
MinTripCount = LoopMinTripCount;
}

if (MinTripCount <= 1) {
LLVM_DEBUG(dbgs() << "Not interesting MinTripCount (<=1)!\n");
return Assessment::TooLowMinTripCount;
Expand Down
14 changes: 13 additions & 1 deletion llvm/lib/Target/AIE/Utils/AIELoopUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@

#define DEBUG_TYPE "aielooputils"

namespace llvm {
cl::opt<int> LoopMinTripCount(
"aie-loop-min-tripcount",
cl::desc("Minimum number of loop iterations (warning: applies to all loop"
" pipelining candidates)"),
cl::init(-1), cl::Hidden);
} // namespace llvm

namespace llvm::AIELoopUtils {
const MDNode *getLoopID(const MachineBasicBlock &LoopBlock) {
const BasicBlock *BBLK = LoopBlock.getBasicBlock();
Expand All @@ -29,7 +37,11 @@ const MDNode *getLoopID(const MachineBasicBlock &LoopBlock) {
}

std::optional<int64_t> getMinTripCount(const MachineBasicBlock &LoopBlock) {
return getMinTripCount(getLoopID(LoopBlock));
std::optional<int64_t> MinTripCount = getMinTripCount(getLoopID(LoopBlock));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes a lot of sense ;-)

if (LoopMinTripCount > MinTripCount.value_or(0)) {
MinTripCount = LoopMinTripCount;
}
return MinTripCount;
}

std::optional<bool> getPipelinerDisabled(const MachineBasicBlock &LoopBlock) {
Expand Down