Skip to content

Add counter for components align#639

Merged
CJ362ff merged 6 commits intoxs-devfrom
add-counter-for-components-align
Dec 11, 2025
Merged

Add counter for components align#639
CJ362ff merged 6 commits intoxs-devfrom
add-counter-for-components-align

Conversation

@CJ362ff
Copy link
Copy Markdown
Contributor

@CJ362ff CJ362ff commented Dec 9, 2025

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced branch prediction statistics with new performance metrics tracking prediction hits, misses, and correctness across multiple predictor types.
    • Improved observability of Return Address Stack behavior with additional tracking metrics.
  • Bug Fixes

    • Fixed potential unsafe memory access by validating prediction data before use.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Dec 9, 2025

Walkthrough

These changes enhance branch prediction statistics tracking across ITTAGE, MGSC, and RAS predictor components by adding new counters to track prediction hits, misses, and correctness outcomes. The commitBranch methods are updated to collect these metrics, and a potential use-after-free issue in ITTAGE is fixed by moving pred_npc extraction within proper bounds checking.

Changes

Cohort / File(s) Summary
ITTAGE Statistics & Safety Fix
src/cpu/pred/btb/btb_ittage.cc
Added eight new public statistics counters (commitHits, callHits, commitMisses, callMisses, commitPredCorrect, commitPredWrong, callPredCorrect, callPredWrong) and fixed pred_npc extraction to occur only within the "pred exists" branch, preventing potential use of invalid pred_npc.
MGSC Statistics & Logic
src/cpu/pred/btb/btb_mgsc.cc, src/cpu/pred/btb/btb_mgsc.hh
Added eight new statistics counters (predHit, predMiss, scPredCorrect, scPredWrong, scPredMissTaken, scPredMissNotTaken, scPredCorrectTageWrong, scPredWrongTageCorrect) and enhanced commitBranch with early-return for non-conditional branches and richer branching outcome tracking.
RAS Statistics Tracking
src/cpu/pred/btb/ras.cc, src/cpu/pred/btb/ras.hh
Introduced new RASStats nested structure with six counters (PredWrong, MispredWithSctr, PredCorrect, CorrectWithSctr, Pushes, Pops), guarded by conditional compilation for UNIT_TEST vs. production, and implemented concrete commitBranch logic to track return instruction prediction outcomes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Safety fix in ITTAGE: The pred_npc scope fix requires careful verification that the condition guard is correct and complete.
  • Conditional compilation in RAS: The UNIT_TEST vs. production split with typedef and struct inheritance needs attention to ensure both code paths are correct.
  • Statistics integration across files: Verify that all new counters are properly initialized, incremented at appropriate points, and consistent with commit-time semantics across ITTAGE, MGSC, and RAS components.

Possibly related PRs

  • Add counter for components #636 — Related due to matching statistics counter additions and commitBranch logic updates across the same BTB predictor component files (btb_ittage, btb_mgsc, ras).

Suggested labels

align-kmhv3

Suggested reviewers

  • jensen-yan
  • Yakkhini
  • tastynoob

Poem

🐰 Hopping through branches with stats in tow,
Each prediction now tracked from high to low,
ITTAGE and MGSC dance with care,
While RAS hops safely through the air,
Counters bloom where the branches grow! 📊

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 31.25% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive The title 'Add counter for components align' is vague and does not clearly describe the primary changes in the pull request, which involve adding comprehensive statistics counters to BTB prediction components (ITTAGE, MGSC, and RAS). Clarify the title to be more specific, such as 'Add prediction statistics counters to BTB components' or 'Enhance ITTAGE, MGSC, and RAS with detailed performance counters'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch add-counter-for-components-align

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (6)
src/cpu/pred/btb/btb_ittage.cc (1)

575-598: Use prefix increment operators for statistics counters.

Static analysis correctly flags that statistics::Scalar is a non-primitive type where prefix ++ operators are more efficient than postfix. Additionally, there's a minor formatting inconsistency at line 591.

Apply this diff to use prefix operators and fix formatting:

     // Update commit statistics
     if (this_branch_hit) {
-        ittageStats.commitHits++;
+        ++ittageStats.commitHits;
         if (pred_npc == npc) {
-            ittageStats.commitPredCorrect++;
+            ++ittageStats.commitPredCorrect;
             if (iscalled) {
-                ittageStats.callPredCorrect++;
+                ++ittageStats.callPredCorrect;
             }
         } else {
-            ittageStats.commitPredWrong++;
+            ++ittageStats.commitPredWrong;
             if (iscalled) {
-                ittageStats.callPredWrong++;
+                ++ittageStats.callPredWrong;
             }
         }
         if (iscalled) {
-            ittageStats.callHits++;
+            ++ittageStats.callHits;
         }
-    }else {
-        ittageStats.commitMisses++;
-        ittageStats.commitPredWrong++;
+    } else {
+        ++ittageStats.commitMisses;
+        ++ittageStats.commitPredWrong;
         if (iscalled) {
-            ittageStats.callMisses++;
-            ittageStats.callPredWrong++;
+            ++ittageStats.callMisses;
+            ++ittageStats.callPredWrong;
         }
     }
src/cpu/pred/btb/btb_tage.cc (2)

1137-1153: Use prefix increment operators and fix formatting.

Static analysis correctly flags that statistics::Scalar is a non-primitive type where prefix ++ operators are more efficient. There's also a formatting inconsistency at line 1142.

Apply this diff:

     if (!predcorrect) {
-        tageStats.condPredwrong++;
+        ++tageStats.condPredwrong;
         if (!pred_hit) {
-            tageStats.condMissTakens++;
+            ++tageStats.condMissTakens;
         }
-    }else{
-        tageStats.condCorrect++;
+    } else {
+        ++tageStats.condCorrect;
         if (!pred_hit) {
-            tageStats.condMissNoTakens++;
+            ++tageStats.condMissNoTakens;
         }
     }

     if (pred_hit) {
-        tageStats.predHit++;
+        ++tageStats.predHit;
     } else {
-        tageStats.predMiss++;
+        ++tageStats.predMiss;
     }

1139-1145: Consider clarifying statistic names for readability.

The names condMissTakens and condMissNoTakens could be misread as tracking taken/not-taken outcomes, but they actually track mispredictions vs correct predictions when there was no TAGE hit. Consider renaming for clarity.

Suggested alternative names:

  • condMissTakenscondMispredOnMiss (misprediction when no hit)
  • condMissNoTakenscondCorrectOnMiss (correct prediction when no hit)

Or document the current names more explicitly in the stat descriptions.

src/cpu/pred/btb/ras.cc (3)

242-242: Consider using prefix increment for statistics counters.

Static analysis suggests preferring prefix ++ operators for non-primitive types. While the performance impact is negligible for statistics::Scalar, prefix is generally preferred for consistency.

-    rasStats.Pushes++;
+    ++rasStats.Pushes;

286-286: Same here: prefer prefix increment.

-    rasStats.Pops++;
+    ++rasStats.Pops;

445-452: Prefer prefix increment for statistics counters.

For consistency with best practices for non-primitive types.

-        rasStats.PredWrong++;
+        ++rasStats.PredWrong;
         if (meta->sctr) {
-            rasStats.MispredWithSctr++;
+            ++rasStats.MispredWithSctr;
         }
     } else {
-        rasStats.PredCorrect++;
+        ++rasStats.PredCorrect;
         if (meta->sctr) {
-            rasStats.CorrectWithSctr++;
+            ++rasStats.CorrectWithSctr;
         }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5b78c77 and 1c050e3.

📒 Files selected for processing (11)
  • configs/example/kmhv3.py (1 hunks)
  • src/cpu/pred/btb/abtb.cc (0 hunks)
  • src/cpu/pred/btb/btb_ittage.cc (2 hunks)
  • src/cpu/pred/btb/btb_ittage.hh (1 hunks)
  • src/cpu/pred/btb/btb_mgsc.cc (2 hunks)
  • src/cpu/pred/btb/btb_mgsc.hh (1 hunks)
  • src/cpu/pred/btb/btb_tage.cc (2 hunks)
  • src/cpu/pred/btb/btb_tage.hh (1 hunks)
  • src/cpu/pred/btb/mbtb.cc (0 hunks)
  • src/cpu/pred/btb/ras.cc (4 hunks)
  • src/cpu/pred/btb/ras.hh (1 hunks)
💤 Files with no reviewable changes (2)
  • src/cpu/pred/btb/mbtb.cc
  • src/cpu/pred/btb/abtb.cc
🧰 Additional context used
🧬 Code graph analysis (5)
configs/example/kmhv3.py (1)
src/cpu/pred/btb/test/abtb.test.cc (1)
  • abtb (59-67)
src/cpu/pred/btb/btb_ittage.cc (1)
src/cpu/pred/btb/btb_ittage.hh (1)
  • stream (114-114)
src/cpu/pred/btb/btb_mgsc.cc (3)
src/cpu/pred/btb/btb_tage.cc (2)
  • commitBranch (1119-1154)
  • commitBranch (1120-1120)
src/cpu/pred/btb/btb_ubtb.cc (2)
  • commitBranch (313-402)
  • commitBranch (314-314)
src/cpu/pred/btb/btb_mgsc.hh (11)
  • stream (162-162)
  • stream (258-258)
  • pc (171-171)
  • pc (216-216)
  • pc (221-221)
  • pc (228-228)
  • pc (231-231)
  • pc (234-234)
  • pc (234-234)
  • pc (248-251)
  • pc (248-248)
src/cpu/pred/btb/btb_tage.cc (3)
src/cpu/pred/btb/btb_mgsc.hh (2)
  • stream (162-162)
  • stream (258-258)
src/cpu/pred/btb/btb_tage.hh (3)
  • stream (155-155)
  • stream (277-277)
  • stream (418-418)
src/cpu/pred/ftb/ftb_tage.hh (1)
  • stream (98-98)
src/cpu/pred/btb/ras.cc (1)
src/cpu/pred/btb/ras.hh (4)
  • stream (107-107)
  • stream (109-109)
  • stream (112-112)
  • RASStats (237-237)
🪛 Cppcheck (2.18.0)
src/cpu/pred/btb/btb_ittage.cc

[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[performance] 576-576: Prefer prefix ++/-- operators for non-primitive types.

(postfixOperator)


[performance] 578-578: Prefer prefix ++/-- operators for non-primitive types.

(postfixOperator)


[performance] 580-580: Prefer prefix ++/-- operators for non-primitive types.

(postfixOperator)


[performance] 583-583: Prefer prefix ++/-- operators for non-primitive types.

(postfixOperator)


[performance] 585-585: Prefer prefix ++/-- operators for non-primitive types.

(postfixOperator)


[performance] 589-589: Prefer prefix ++/-- operators for non-primitive types.

(postfixOperator)


[performance] 592-592: Prefer prefix ++/-- operators for non-primitive types.

(postfixOperator)


[performance] 593-593: Prefer prefix ++/-- operators for non-primitive types.

(postfixOperator)


[performance] 595-595: Prefer prefix ++/-- operators for non-primitive types.

(postfixOperator)


[performance] 596-596: Prefer prefix ++/-- operators for non-primitive types.

(postfixOperator)


[information] Too many #ifdef configurations - cppcheck only checks 12 configurations. Use --force to check all configurations. For more details, use --enable=information.

(toomanyconfigs)


[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[information] Too many #ifdef configurations - cppcheck only checks 12 configurations. Use --force to check all configurations. For more details, use --enable=information.

(toomanyconfigs)

src/cpu/pred/btb/btb_mgsc.cc

[information] 4-4: Include file

(missingIncludeSystem)


[information] 5-5: Include file

(missingIncludeSystem)


[information] 6-6: Include file

(missingIncludeSystem)


[information] 7-7: Include file

(missingIncludeSystem)


[information] 4-4: Include file

(missingIncludeSystem)


[information] 5-5: Include file

(missingIncludeSystem)


[information] 7-7: Include file

(missingIncludeSystem)


[information] 4-4: Include file

(missingIncludeSystem)


[information] 6-6: Include file

(missingIncludeSystem)


[information] 7-7: Include file

(missingIncludeSystem)


[information] 5-5: Include file

(missingIncludeSystem)


[information] 6-6: Include file

(missingIncludeSystem)


[information] 5-5: Include file

(missingIncludeSystem)


[information] 4-4: Include file

(missingIncludeSystem)


[information] 5-5: Include file

(missingIncludeSystem)


[information] 7-7: Include file

(missingIncludeSystem)


[information] 4-4: Include file

(missingIncludeSystem)


[information] 5-5: Include file

(missingIncludeSystem)


[information] 6-6: Include file

(missingIncludeSystem)


[information] 5-5: Include file

(missingIncludeSystem)


[information] 6-6: Include file

(missingIncludeSystem)


[information] 4-4: Include file

(missingIncludeSystem)


[information] 5-5: Include file

(missingIncludeSystem)


[information] 6-6: Include file

(missingIncludeSystem)


[information] 7-7: Include file

(missingIncludeSystem)


[information] 4-4: Include file

(missingIncludeSystem)


[information] 5-5: Include file

(missingIncludeSystem)


[information] 6-6: Include file

(missingIncludeSystem)


[information] 7-7: Include file

(missingIncludeSystem)


[information] 4-4: Include file

(missingIncludeSystem)


[information] 5-5: Include file

(missingIncludeSystem)


[information] 6-6: Include file

(missingIncludeSystem)


[information] 7-7: Include file

(missingIncludeSystem)


[information] 4-4: Include file

(missingIncludeSystem)


[information] 5-5: Include file

(missingIncludeSystem)


[information] 6-6: Include file

(missingIncludeSystem)


[information] 7-7: Include file

(missingIncludeSystem)


[information] 4-4: Include file

(missingIncludeSystem)


[information] 5-5: Include file

(missingIncludeSystem)


[information] 6-6: Include file

(missingIncludeSystem)


[information] 7-7: Include file

(missingIncludeSystem)


[information] 4-4: Include file

(missingIncludeSystem)


[information] 5-5: Include file

(missingIncludeSystem)


[information] 6-6: Include file

(missingIncludeSystem)


[information] 7-7: Include file

(missingIncludeSystem)


[information] 4-4: Include file

(missingIncludeSystem)


[information] 4-4: Include file

(missingIncludeSystem)


[information] 5-5: Include file

(missingIncludeSystem)


[information] 6-6: Include file

(missingIncludeSystem)


[information] 7-7: Include file

(missingIncludeSystem)


[information] 4-4: Include file

(missingIncludeSystem)


[information] 5-5: Include file

(missingIncludeSystem)


[information] 4-4: Include file

(missingIncludeSystem)


[information] 5-5: Include file

(missingIncludeSystem)


[information] 6-6: Include file

(missingIncludeSystem)


[information] 7-7: Include file

(missingIncludeSystem)


[information] 4-4: Include file

(missingIncludeSystem)


[information] 4-4: Include file

(missingIncludeSystem)


[information] 5-5: Include file

(missingIncludeSystem)


[information] 6-6: Include file

(missingIncludeSystem)


[information] 7-7: Include file

(missingIncludeSystem)


[information] 4-4: Include file

(missingIncludeSystem)


[information] 5-5: Include file

(missingIncludeSystem)


[information] 6-6: Include file

(missingIncludeSystem)


[information] 7-7: Include file

(missingIncludeSystem)


[information] 4-4: Include file

(missingIncludeSystem)


[information] 5-5: Include file

(missingIncludeSystem)


[information] 6-6: Include file

(missingIncludeSystem)


[information] 7-7: Include file

(missingIncludeSystem)


[information] 4-4: Include file

(missingIncludeSystem)


[information] 5-5: Include file

(missingIncludeSystem)


[information] 6-6: Include file

(missingIncludeSystem)


[information] 7-7: Include file

(missingIncludeSystem)


[information] 4-4: Include file

(missingIncludeSystem)


[information] 5-5: Include file

(missingIncludeSystem)


[information] 6-6: Include file

(missingIncludeSystem)


[information] 7-7: Include file

(missingIncludeSystem)


[information] 4-4: Include file

(missingIncludeSystem)


[information] 6-6: Include file

(missingIncludeSystem)


[information] 4-4: Include file

(missingIncludeSystem)


[information] 5-5: Include file

(missingIncludeSystem)


[information] 6-6: Include file

(missingIncludeSystem)


[information] 5-5: Include file

(missingIncludeSystem)


[information] 4-4: Include file

(missingIncludeSystem)


[information] 5-5: Include file

(missingIncludeSystem)


[information] 6-6: Include file

(missingIncludeSystem)


[information] 4-4: Include file

(missingIncludeSystem)


[information] 5-5: Include file

(missingIncludeSystem)


[information] 6-6: Include file

(missingIncludeSystem)


[information] 7-7: Include file

(missingIncludeSystem)


[information] 4-4: Include file

(missingIncludeSystem)


[information] 5-5: Include file

(missingIncludeSystem)


[information] 6-6: Include file

(missingIncludeSystem)


[information] 7-7: Include file

(missingIncludeSystem)


[information] 4-4: Include file

(missingIncludeSystem)


[information] 4-4: Include file

(missingIncludeSystem)


[information] 5-5: Include file

(missingIncludeSystem)


[information] 7-7: Include file

(missingIncludeSystem)


[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[information] Too many #ifdef configurations - cppcheck only checks 12 configurations. Use --force to check all configurations. For more details, use --enable=information.

(toomanyconfigs)


[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[performance] 1118-1118: Prefer prefix ++/-- operators for non-primitive types.

(postfixOperator)


[performance] 1120-1120: Prefer prefix ++/-- operators for non-primitive types.

(postfixOperator)


[performance] 1122-1122: Prefer prefix ++/-- operators for non-primitive types.

(postfixOperator)


[performance] 1125-1125: Prefer prefix ++/-- operators for non-primitive types.

(postfixOperator)


[performance] 1127-1127: Prefer prefix ++/-- operators for non-primitive types.

(postfixOperator)


[performance] 1131-1131: Prefer prefix ++/-- operators for non-primitive types.

(postfixOperator)


[performance] 1133-1133: Prefer prefix ++/-- operators for non-primitive types.

(postfixOperator)


[performance] 1134-1134: Prefer prefix ++/-- operators for non-primitive types.

(postfixOperator)


[performance] 1136-1136: Prefer prefix ++/-- operators for non-primitive types.

(postfixOperator)


[performance] 1139-1139: Prefer prefix ++/-- operators for non-primitive types.

(postfixOperator)


[performance] 1140-1140: Prefer prefix ++/-- operators for non-primitive types.

(postfixOperator)


[performance] 1142-1142: Prefer prefix ++/-- operators for non-primitive types.

(postfixOperator)


[information] Too many #ifdef configurations - cppcheck only checks 12 configurations. Use --force to check all configurations. For more details, use --enable=information.

(toomanyconfigs)

src/cpu/pred/btb/btb_tage.cc

[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[information] Too many #ifdef configurations - cppcheck only checks 12 configurations. Use --force to check all configurations. For more details, use --enable=information.

(toomanyconfigs)


[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[performance] 1138-1138: Prefer prefix ++/-- operators for non-primitive types.

(postfixOperator)


[performance] 1140-1140: Prefer prefix ++/-- operators for non-primitive types.

(postfixOperator)


[performance] 1143-1143: Prefer prefix ++/-- operators for non-primitive types.

(postfixOperator)


[performance] 1145-1145: Prefer prefix ++/-- operators for non-primitive types.

(postfixOperator)


[performance] 1150-1150: Prefer prefix ++/-- operators for non-primitive types.

(postfixOperator)


[performance] 1152-1152: Prefer prefix ++/-- operators for non-primitive types.

(postfixOperator)


[information] Too many #ifdef configurations - cppcheck only checks 12 configurations. Use --force to check all configurations. For more details, use --enable=information.

(toomanyconfigs)

src/cpu/pred/btb/ras.cc

[information] 54-54: Include file

(missingIncludeSystem)


[information] 55-55: Include file

(missingIncludeSystem)


[information] 54-54: Include file

(missingInclude)


[information] 54-54: Include file

(missingIncludeSystem)


[information] 55-55: Include file

(missingIncludeSystem)


[information] 54-54: Include file

(missingInclude)


[information] 54-54: Include file

(missingInclude)


[information] 55-55: Include file

(missingInclude)


[information] 55-55: Include file

(missingInclude)


[information] 55-55: Include file

(missingIncludeSystem)


[information] 55-55: Include file

(missingInclude)


[information] 54-54: Include file

(missingInclude)


[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[performance] 55-55: Function 'getNonSpecStack()' should return member 'nonSpecStack' by const reference.

(returnByReference)


[information] Too many #ifdef configurations - cppcheck only checks 12 configurations. Use --force to check all configurations. For more details, use --enable=information.

(toomanyconfigs)


[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[performance] 242-242: Prefer prefix ++/-- operators for non-primitive types.

(postfixOperator)


[information] Too many #ifdef configurations - cppcheck only checks 12 configurations. Use --force to check all configurations. For more details, use --enable=information.

(toomanyconfigs)


[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[performance] 286-286: Prefer prefix ++/-- operators for non-primitive types.

(postfixOperator)


[information] Too many #ifdef configurations - cppcheck only checks 12 configurations. Use --force to check all configurations. For more details, use --enable=information.

(toomanyconfigs)


[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[performance] 438-438: Variable 'preds' is assigned in constructor body. Consider performing initialization in initialization list.

(useInitializationList)


[performance] 439-439: Variable 'indexBwFoldedHist' is assigned in constructor body. Consider performing initialization in initialization list.

(useInitializationList)


[performance] 440-440: Variable 'indexLFoldedHist' is assigned in constructor body. Consider performing initialization in initialization list.

(useInitializationList)


[performance] 441-441: Variable 'indexIFoldedHist' is assigned in constructor body. Consider performing initialization in initialization list.

(useInitializationList)


[performance] 442-442: Variable 'indexGFoldedHist' is assigned in constructor body. Consider performing initialization in initialization list.

(useInitializationList)


[performance] 443-443: Variable 'indexPFoldedHist' is assigned in constructor body. Consider performing initialization in initialization list.

(useInitializationList)


[performance] 445-445: Prefer prefix ++/-- operators for non-primitive types.

(postfixOperator)


[performance] 447-447: Prefer prefix ++/-- operators for non-primitive types.

(postfixOperator)


[performance] 450-450: Prefer prefix ++/-- operators for non-primitive types.

(postfixOperator)


[performance] 452-452: Prefer prefix ++/-- operators for non-primitive types.

(postfixOperator)


[information] Too many #ifdef configurations - cppcheck only checks 12 configurations. Use --force to check all configurations. For more details, use --enable=information.

(toomanyconfigs)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: perf_test / XS-GEM5 - Run performance test (spec06-0.3c)
🔇 Additional comments (14)
configs/example/kmhv3.py (1)

93-109: ABTB enablement in KMH v3 branch predictor config looks consistent

Turning cpu.branchPred.abtb.enabled to True under the DecoupledBPUWithBTB configuration is consistent with the surrounding predictor setup (ubtb, mbtb, tage enabled; ittage, mgsc, ras disabled). I don’t see configuration or wiring issues in this block.

src/cpu/pred/btb/btb_ittage.hh (1)

220-228: LGTM! New commit-time statistics members added.

The eight new statistics members provide comprehensive tracking for ITTAGE commit behavior, covering hits/misses and prediction correctness for both general indirect branches and calls specifically.

src/cpu/pred/btb/btb_ittage.cc (2)

558-561: LGTM! Proper filtering for indirect non-return branches.

The early return correctly scopes ITTAGE statistics to only indirect control flow instructions that are not returns, matching the predictor's purpose.


616-625: LGTM! Statistics properly initialized.

The new commit-time statistics are correctly registered with descriptive labels following the existing pattern.

src/cpu/pred/btb/btb_tage.cc (2)

1032-1039: LGTM! New conditional branch statistics properly registered.

The six new statistics for tracking conditional branch commit behavior are correctly initialized with appropriate descriptions.


1122-1125: LGTM! Proper filtering for conditional branches.

The early return correctly scopes TAGE statistics to only conditional control flow instructions, matching the predictor's purpose.

src/cpu/pred/btb/btb_tage.hh (1)

366-372: LGTM! New conditional branch statistics members added.

The six new statistics members properly extend TageStats to track commit-time behavior for conditional branches, consistent with the parallel additions in ITTAGE.

src/cpu/pred/btb/btb_mgsc.hh (1)

392-399: LGTM!

The new statistics counters are well-organized and follow the existing pattern in the struct. The naming clearly indicates their purpose for tracking commit-time prediction statistics.

src/cpu/pred/btb/btb_mgsc.cc (2)

3-6: LGTM!

The UNIT_TEST guard allows compiling this module without the full O3 CPU dependencies during unit testing, which is a good practice for testability.


1085-1094: LGTM!

The new statistics are properly initialized with appropriate descriptions. They align with the header declarations and follow the existing pattern.

src/cpu/pred/btb/ras.hh (1)

215-219: LGTM on the Scalar typedef approach.

The conditional typedef pattern cleanly abstracts away the difference between test and production statistics types.

src/cpu/pred/btb/ras.cc (3)

54-55: LGTM on constructor initialization.

Properly initializes rasStats with this to register the statistics group with the parent.


435-455: LGTM on the commitBranch implementation.

The logic correctly:

  1. Filters to only return instructions (excluding NOPs) at line 438.
  2. Retrieves the prediction metadata and actual next PC.
  3. Compares predicted target against actual NPC to determine prediction correctness.
  4. Tracks the sctr > 0 correlation for deeper analysis of mispredictions with counter-compressed stack entries.

457-470: LGTM on RASStats constructor.

The statistics are properly registered using ADD_STAT with appropriate units and descriptions.

@XiangShanRobot
Copy link
Copy Markdown

[Generated by GEM5 Performance Robot]
commit: 1c050e3
workflow: gem5 Ideal BTB Performance Test

Ideal BTB Performance

Overall Score

PR Master Diff(%)
Score 14.97 19.83 -24.51 🔴

[Generated by GEM5 Performance Robot]
commit: 1c050e3
workflow: gem5 Ideal BTB Performance Test

Ideal BTB Performance

Overall Score

PR Previous Commit Diff(%)
Score 14.97 14.95 +0.15 🟢

@CJ362ff CJ362ff requested a review from jensen-yan December 9, 2025 07:10
jensen-yan
jensen-yan previously approved these changes Dec 10, 2025
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/cpu/pred/btb/btb_ittage.cc (1)

574-578: Guarded pred_npc assignment removes the UB; optional clarity tweak

Moving the pred_npc assignment behind the pred_it != meta->preds.end() check correctly avoids dereferencing end() and fixes the prior undefined behavior. As a small readability/diagnostics tweak, you might want to initialize pred_npc (e.g., Addr pred_npc = 0;) to make it obviously safe even if the compiler can’t prove the this_branch_hit guard, but functionally this is fine as-is.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1c050e3 and 9d5c217.

📒 Files selected for processing (1)
  • src/cpu/pred/btb/btb_ittage.cc (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/cpu/pred/btb/btb_ittage.cc (1)
src/cpu/pred/btb/btb_ubtb.hh (1)
  • meta (144-147)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Quick Build, Unit Tests & Smoke Test
  • GitHub Check: perf_test / XS-GEM5 - Run performance test (spec06-0.3c)
🔇 Additional comments (2)
src/cpu/pred/btb/btb_ittage.cc (2)

582-605: Confirm intended semantics for *_PredWrong on ITTAGE misses

Right now, commitPredWrong (and callPredWrong) is incremented both when:

  • there is an ITTAGE hit but the predicted target (pred_npc) is wrong, and
  • there is no ITTAGE prediction at all (miss branch).

That makes commitPredCorrect + commitPredWrong equal the total number of indirect (and call) commits, while commitHits + commitMisses tracks presence/absence of an ITTAGE entry. If instead you want “*_PredWrong” to count only cases where ITTAGE actually provided a prediction that turned out wrong (excluding pure misses), you’d drop the *_PredWrong increments from the else (miss) path and rely solely on *_Misses there.

Please double-check which definition you want for downstream analysis and adjust accordingly if needed.


625-632: New commit/call stats wiring looks consistent

The added commitHits/Misses, callHits/Misses, and commitPred*/callPred* counters are cleanly registered and match the updates in commitBranch, so the stats plumbing itself looks correct.

@github-actions
Copy link
Copy Markdown

🚀 Coremark Smoke Test Results

Branch IPC Change
Base (xs-dev) 1.6750 -
This PR 1.6750 ➡️ 0.0000 (0.00%)

✅ Difftest smoke test passed!

@CJ362ff CJ362ff requested a review from jensen-yan December 10, 2025 08:31
@CJ362ff CJ362ff merged commit 2afe252 into xs-dev Dec 11, 2025
2 of 3 checks passed
@CJ362ff CJ362ff deleted the add-counter-for-components-align branch December 11, 2025 02:18
@coderabbitai coderabbitai bot mentioned this pull request Dec 15, 2025
This was referenced Dec 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants