From dffec12f33cc0387a323e065638486f2e2bc23c4 Mon Sep 17 00:00:00 2001 From: Andrea Di Biagio Date: Fri, 9 Nov 2018 12:29:57 +0000 Subject: [llvm-mca] Use a small vector for instructions in the EntryStage. Use a simple SmallVector to track the lifetime of simulated instructions. An ordered map was not needed because instructions are already picked in program order. It is also much faster if we avoid searching for already retired instructions at the end of every cycle. The new policy only triggers a "garbage collection" when the number of retired instructions becomes significantly big when compared with the total size of the vector. While working on this, I noticed that instructions were correctly retired, but their internal state was not updated (i.e. there was no transition from the EXECUTED state, to the RETIRED state). While this was not a problem for the views, it prevented the EntryStage from correctly garbage collecting already retired instructions. That was a bad oversight, and this patch fixes it. The observed speedup on a debug build of llvm-mca after this patch is ~6%. On a release build of llvm-mca, the observed speedup is ~%15%. llvm-svn: 346487 --- llvm/tools/llvm-mca/lib/HardwareUnits/RetireControlUnit.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'llvm/tools/llvm-mca/lib/HardwareUnits') diff --git a/llvm/tools/llvm-mca/lib/HardwareUnits/RetireControlUnit.cpp b/llvm/tools/llvm-mca/lib/HardwareUnits/RetireControlUnit.cpp index 0456e1d7a5b..bd7b411af11 100644 --- a/llvm/tools/llvm-mca/lib/HardwareUnits/RetireControlUnit.cpp +++ b/llvm/tools/llvm-mca/lib/HardwareUnits/RetireControlUnit.cpp @@ -60,9 +60,10 @@ const RetireControlUnit::RUToken &RetireControlUnit::peekCurrentToken() const { } void RetireControlUnit::consumeCurrentToken() { - const RetireControlUnit::RUToken &Current = peekCurrentToken(); + RetireControlUnit::RUToken &Current = Queue[CurrentInstructionSlotIdx]; assert(Current.NumSlots && "Reserved zero slots?"); assert(Current.IR && "Invalid RUToken in the RCU queue."); + Current.IR.getInstruction()->retire(); // Update the slot index to be the next item in the circular queue. CurrentInstructionSlotIdx += Current.NumSlots; -- cgit v1.2.3