Distance-Based Branch Prediction for Path-Dependent Targets
Solution Overview
Problem
Existing branch prediction methods struggle to accurately predict target instruction addresses for branches whose targets depend on the path taken to arrive at the branch, especially in systems without well-defined call and return instructions, leading to inefficiencies and errors in processing systems.
Innovation Solution
Implementing a distance-based branch prediction method that uses a call-return stack to identify potential return instruction addresses by determining relationships between target and branch instruction addresses, allowing for accurate prediction without requiring architectural changes or recompilation of code, and utilizing a processing system with a branch detection module and prediction module to mark and validate call-like and return-like branches.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Measurement precision
If a branch target buffer (BTB) is used to store target instruction addresses, then branch prediction accuracy is improved for branches with fixed targets, but prediction fails for branches whose targets depend on the path taken to arrive at the branch
Solution Approach 1:
The patent segments the branch prediction problem into two distinct parts: a Branch Target Buffer (BTB) for storing static target addresses and a Changing Target Buffer (CTB) for handling path-dependent branches. The BTB stores entries with branch addresses and their static targets, while the CTB dynamically updates targets based on taken branches along the execution path. This segmentation allows each structure to specialize in one type of branch prediction, resolving the contradiction between accuracy for fixed targets and adaptability for path-dependent targets.
Solution Approach 2:
The patent introduces a path history buffer as an intermediary structure that records the sequence of taken branches leading to the current branch. This intermediary allows the system to determine which path was taken and use that information to select the correct target from the CTB, enabling accurate prediction for path-dependent branches without requiring architectural changes to the processor core.
2Adaptability or versatility
If history based structures like changing target buffer (CTB) are used to predict path-dependent branches, then adaptability is improved, but system complexity increases
Solution Approach 1:
The patent divides the prediction system into separate specialized structures: BTB for static targets, CTB for dynamic targets, and path history buffer for tracking execution paths. Each structure has a specific, simplified function rather than one complex structure trying to handle all cases. This segmentation reduces the complexity of individual components while maintaining overall system adaptability.
Solution Approach 2:
The system performs preliminary actions by pre-computing and storing possible target addresses in the CTB for each branch, organized by potential paths. When a branch is encountered, the path history buffer is consulted to determine which pre-computed target is correct, avoiding the need for complex real-time calculations and reducing the complexity of the prediction logic.
3Reliability
If the pipeline waits for branch resolution without prediction, then prediction accuracy is not compromised, but processing speed decreases due to pipeline stalls
Solution Approach 1:
The patent performs preliminary actions by predicting branch targets before the actual branch resolution is available. The BTB and CTB store pre-computed target addresses that can be used immediately by the pipeline, allowing speculation about the branch outcome. This eliminates pipeline stalls because the pipeline can continue executing instructions based on predicted targets while the actual branch resolution is pending.
Solution Approach 2:
The system uses feedback mechanisms to validate predictions. When the actual branch resolution becomes available, it is compared with the predicted target. If the prediction is correct, the pipeline continues without interruption. If incorrect, the pipeline is flushed and restarted from the correct address. This feedback loop maintains reliability by correcting errors while preserving speed through most correct predictions.
Data Source
AI summary
Examples of techniques for distance-based branch prediction are disclosed. In one example implementation according to aspects of the present disclosure, a computer-implemented method includes: determining, by a processing system, a potential return instruction address (IA) by determining whether a relationship is satisfied between a first target IA and a first branch IA; storing a second branch IA as a return when a target IA of a second branch matches a potential return IA for the second branch; and applying the potential return IA for the second branch as a predicted target IA of a predicted branch IA stored as a return.


