Skip to content

Conversation

@jserv
Copy link
Contributor

@jserv jserv commented Jan 16, 2026

This extracts duplicated BHT logic into reusable inline helpers:

  • bht_find_max_idx(): find most frequent indirect jump target
  • bht_find_min_idx(): find LFU replacement slot
  • bht_should_translate(): check JIT translation threshold

Summary by cubic

Refactored branch history table logic into small inline helpers to remove duplication and make JIT translation decisions consistent.

  • Refactors
    • Added bht_find_max_idx to pick the most frequent indirect jump target.
    • Added bht_find_min_idx for LFU replacement (returns first empty slot).
    • Added bht_should_translate to centralize threshold and SATP checks; used in parse_branch_history_table and translate_chained_block.
    • Updated rv32_template to use bht_find_min_idx when recording branch targets.

Written for commit 5fe0bcb. Summary will update on new commits.

This extracts duplicated BHT logic into reusable inline helpers:
- bht_find_max_idx(): find most frequent indirect jump target
- bht_find_min_idx(): find LFU replacement slot
- bht_should_translate(): check JIT translation threshold
@jserv jserv added this to the release-2026.1 milestone Jan 16, 2026
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 3 files

Copy link
Contributor Author

@jserv jserv left a comment

Choose a reason for hiding this comment

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

Benchmarks

Details
Benchmark suite Current: 5fe0bcb Previous: 50a75ef Ratio
Dhrystone 1633.333 DMIPS 1624 DMIPS 0.99
CoreMark 952.119 iterations/sec 950.045 iterations/sec 1.00

This comment was automatically generated by workflow using github-action-benchmark.

@jserv jserv merged commit 0fde374 into master Jan 16, 2026
23 checks passed
@jserv jserv deleted the simplify-branch branch January 16, 2026 23:03
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.

2 participants