[llvm-mca] Correctly set the ReadAdvance information for register use operands.
The tool was passing the wrong operand index to method
MCSubtargetInfo::getReadAdvanceCycles(). That method requires a "UseIdx", and
not the operand index. This was found when testing X86 code where instructions
had a memory folded operand.
This patch fixes the issue and adds test read-advance-1.s to ensure that
the ReadAfterLd (a ReadAdvance of 3cy) information is correctly used.
llvm-svn: 328790
diff --git a/llvm/tools/llvm-mca/Instruction.cpp b/llvm/tools/llvm-mca/Instruction.cpp
index de7c5c6..77b9967 100644
--- a/llvm/tools/llvm-mca/Instruction.cpp
+++ b/llvm/tools/llvm-mca/Instruction.cpp
@@ -98,9 +98,7 @@
RCUTokenID = RCUToken;
// Check if input operands are already available.
- if (std::all_of(Uses.begin(), Uses.end(),
- [](const UniqueUse &Use) { return Use->isReady(); }))
- Stage = IS_READY;
+ update();
}
void Instruction::execute() {
@@ -122,19 +120,22 @@
return Desc.MaxLatency == 0 && Defs.size() == 0 && Uses.size() == 0;
}
+void Instruction::update() {
+ if (!isDispatched())
+ return;
+
+ if (llvm::all_of(Uses, [](const UniqueUse &Use) { return Use->isReady(); }))
+ Stage = IS_READY;
+}
+
void Instruction::cycleEvent() {
if (isReady())
return;
if (isDispatched()) {
- bool IsReady = true;
- for (UniqueUse &Use : Uses) {
+ for (UniqueUse &Use : Uses)
Use->cycleEvent();
- IsReady &= Use->isReady();
- }
-
- if (IsReady)
- Stage = IS_READY;
+ update();
return;
}