[llvm] f11a2ab - [MCA] Retire all non-carried-over instructions in InOrderIssueStage (#176686)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 20 10:20:19 PST 2026
Author: Aiden Grossman
Date: 2026-01-20T18:20:14Z
New Revision: f11a2ab58789abab88998a1a7d7125431010b2a0
URL: https://github.com/llvm/llvm-project/commit/f11a2ab58789abab88998a1a7d7125431010b2a0
DIFF: https://github.com/llvm/llvm-project/commit/f11a2ab58789abab88998a1a7d7125431010b2a0.diff
LOG: [MCA] Retire all non-carried-over instructions in InOrderIssueStage (#176686)
Otherwise we might be left with instructions that never retire which can
create some weird results. This showed up originally on the MCA
timeline.
Fixes #176103.
Added:
llvm/test/tools/llvm-mca/AArch64/cortex-a55-carry-over.s
Modified:
llvm/lib/MCA/Stages/InOrderIssueStage.cpp
Removed:
################################################################################
diff --git a/llvm/lib/MCA/Stages/InOrderIssueStage.cpp b/llvm/lib/MCA/Stages/InOrderIssueStage.cpp
index 30def19b1879a..9590ebfd3201f 100644
--- a/llvm/lib/MCA/Stages/InOrderIssueStage.cpp
+++ b/llvm/lib/MCA/Stages/InOrderIssueStage.cpp
@@ -294,10 +294,10 @@ void InOrderIssueStage::updateIssuedInst() {
continue;
}
- // If the instruction takes multiple cycles to issue, defer these calls
+ // If an instruction takes multiple cycles to issue, defer these calls
// to updateCarriedOver. We still remove from IssuedInst even if there is
// carry over to avoid an extra call to cycleEvent in the next cycle.
- if (!CarriedOver) {
+ if (CarriedOver.getInstruction() != IR.getInstruction()) {
PRF.onInstructionExecuted(&IS);
LSU.onInstructionExecuted(IR);
notifyInstructionExecuted(IR);
diff --git a/llvm/test/tools/llvm-mca/AArch64/cortex-a55-carry-over.s b/llvm/test/tools/llvm-mca/AArch64/cortex-a55-carry-over.s
new file mode 100644
index 0000000000000..a456e608b5ec3
--- /dev/null
+++ b/llvm/test/tools/llvm-mca/AArch64/cortex-a55-carry-over.s
@@ -0,0 +1,82 @@
+# NOTE: Assertions have been autogenerated by utils/update_mca_test_checks.py
+# RUN: llvm-mca -mtriple=aarch64 -mcpu=cortex-a55 -timeline -iterations=2 < %s | FileCheck %s
+
+stp x29, x0, [sp, #-16]!
+ldp x29, x0, [sp], #16
+mov w0, wzr
+ret
+
+# CHECK: Iterations: 2
+# CHECK-NEXT: Instructions: 8
+# CHECK-NEXT: Total Cycles: 11
+# CHECK-NEXT: Total uOps: 14
+
+# CHECK: Dispatch Width: 2
+# CHECK-NEXT: uOps Per Cycle: 1.27
+# CHECK-NEXT: IPC: 0.73
+# CHECK-NEXT: Block RThroughput: 3.5
+
+# CHECK: Instruction Info:
+# CHECK-NEXT: [1]: #uOps
+# CHECK-NEXT: [2]: Latency
+# CHECK-NEXT: [3]: RThroughput
+# CHECK-NEXT: [4]: MayLoad
+# CHECK-NEXT: [5]: MayStore
+# CHECK-NEXT: [6]: HasSideEffects (U)
+
+# CHECK: [1] [2] [3] [4] [5] [6] Instructions:
+# CHECK-NEXT: 2 1 1.00 * stp x29, x0, [sp, #-16]!
+# CHECK-NEXT: 3 5 2.00 * ldp x29, x0, [sp], #16
+# CHECK-NEXT: 1 3 0.50 mov w0, wzr
+# CHECK-NEXT: 1 1 1.00 U ret
+
+# CHECK: Resources:
+# CHECK-NEXT: [0.0] - CortexA55UnitALU
+# CHECK-NEXT: [0.1] - CortexA55UnitALU
+# CHECK-NEXT: [1] - CortexA55UnitB
+# CHECK-NEXT: [2] - CortexA55UnitDiv
+# CHECK-NEXT: [3.0] - CortexA55UnitFPALU
+# CHECK-NEXT: [3.1] - CortexA55UnitFPALU
+# CHECK-NEXT: [4] - CortexA55UnitFPDIV
+# CHECK-NEXT: [5.0] - CortexA55UnitFPMAC
+# CHECK-NEXT: [5.1] - CortexA55UnitFPMAC
+# CHECK-NEXT: [6] - CortexA55UnitLd
+# CHECK-NEXT: [7] - CortexA55UnitMAC
+# CHECK-NEXT: [8] - CortexA55UnitSt
+
+# CHECK: Resource pressure per iteration:
+# CHECK-NEXT: [0.0] [0.1] [1] [2] [3.0] [3.1] [4] [5.0] [5.1] [6] [7] [8]
+# CHECK-NEXT: 0.50 0.50 1.00 - - - - - - 2.00 - 1.00
+
+# CHECK: Resource pressure by instruction:
+# CHECK-NEXT: [0.0] [0.1] [1] [2] [3.0] [3.1] [4] [5.0] [5.1] [6] [7] [8] Instructions:
+# CHECK-NEXT: - - - - - - - - - - - 1.00 stp x29, x0, [sp, #-16]!
+# CHECK-NEXT: - - - - - - - - - 2.00 - - ldp x29, x0, [sp], #16
+# CHECK-NEXT: 0.50 0.50 - - - - - - - - - - mov w0, wzr
+# CHECK-NEXT: - - 1.00 - - - - - - - - - ret
+
+# CHECK: Timeline view:
+# CHECK-NEXT: 0
+# CHECK-NEXT: Index 0123456789
+
+# CHECK: [0,0] DE . . stp x29, x0, [sp, #-16]!
+# CHECK-NEXT: [0,1] DeeeeE . ldp x29, x0, [sp], #16
+# CHECK-NEXT: [0,2] . DeeE . mov w0, wzr
+# CHECK-NEXT: [0,3] . DE . ret
+# CHECK-NEXT: [1,0] . DE . stp x29, x0, [sp, #-16]!
+# CHECK-NEXT: [1,1] . DeeeeE ldp x29, x0, [sp], #16
+# CHECK-NEXT: [1,2] . . DeeE mov w0, wzr
+# CHECK-NEXT: [1,3] . . DE ret
+
+# CHECK: Average Wait times (based on the timeline view):
+# CHECK-NEXT: [0]: Executions
+# CHECK-NEXT: [1]: Average time spent waiting in a scheduler's queue
+# CHECK-NEXT: [2]: Average time spent waiting in a scheduler's queue while ready
+# CHECK-NEXT: [3]: Average time elapsed from WB until retire stage
+
+# CHECK: [0] [1] [2] [3]
+# CHECK-NEXT: 0. 2 0.0 0.0 0.0 stp x29, x0, [sp, #-16]!
+# CHECK-NEXT: 1. 2 0.0 0.0 0.0 ldp x29, x0, [sp], #16
+# CHECK-NEXT: 2. 2 0.0 0.0 0.0 mov w0, wzr
+# CHECK-NEXT: 3. 2 0.0 0.0 0.0 ret
+# CHECK-NEXT: 2 0.0 0.0 0.0 <total>
More information about the llvm-commits
mailing list