[llvm-mca] Avoid calling method update() on instructions that are already in the IS_READY state. NFCI
When promoting instructions from the wait queue to the ready queue, we should
check if an instruction has already reached the IS_READY state before
calling method update().
llvm-svn: 335722
diff --git a/llvm/tools/llvm-mca/Instruction.cpp b/llvm/tools/llvm-mca/Instruction.cpp
index 3abf30c..f84c781 100644
--- a/llvm/tools/llvm-mca/Instruction.cpp
+++ b/llvm/tools/llvm-mca/Instruction.cpp
@@ -32,8 +32,10 @@
--DependentWrites;
TotalCycles = std::max(TotalCycles, Cycles);
- if (!DependentWrites)
+ if (!DependentWrites) {
CyclesLeft = TotalCycles;
+ IsReady = !CyclesLeft;
+ }
}
void WriteState::onInstructionIssued() {
@@ -83,8 +85,10 @@
if (CyclesLeft == UNKNOWN_CYCLES)
return;
- if (CyclesLeft)
+ if (CyclesLeft) {
--CyclesLeft;
+ IsReady = !CyclesLeft;
+ }
}
#ifndef NDEBUG
@@ -119,9 +123,7 @@
}
void Instruction::update() {
- if (!isDispatched())
- return;
-
+ assert(isDispatched() && "Unexpected instruction stage found!");
if (llvm::all_of(Uses, [](const UniqueUse &Use) { return Use->isReady(); }))
Stage = IS_READY;
}
@@ -131,9 +133,14 @@
return;
if (isDispatched()) {
- for (UniqueUse &Use : Uses)
+ bool IsReady = true;
+ for (UniqueUse &Use : Uses) {
Use->cycleEvent();
- update();
+ IsReady &= Use->isReady();
+ }
+
+ if (IsReady)
+ Stage = IS_READY;
return;
}