A branch taken address prediction system and method
By adding a BTB writing mechanism to the branch jump address prediction system, and using the store instruction to directly write to the BTB, the problem of inaccurate indirect jump address prediction is solved, the accuracy and reliability of branch prediction are improved, and program performance is enhanced.
Patent Information
- Application Number
- CN202611066780.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-16
- Publication Date
- 2026-11-20
AI Technical Summary
Existing branch jump address prediction systems have low accuracy and reliability when processing indirect jump instructions, especially because the jump address depends on the value of the register file and is difficult to predict accurately.
In the branch jump address prediction system, a new BTB writing mechanism is added, which enables the store instruction to directly write the jump address into the BTB through the target data path, thereby improving the prediction accuracy and reliability.
This improves the accuracy and reliability of branch jump address prediction results, thereby enhancing program performance.
Smart Images

Figure CN123137724A_ABST
Abstract
Description
Technical Field
[0001] This disclosure generally relates to branch prediction techniques, and more particularly to a branch jump address prediction system and method. Background Technology
[0002] Branch prediction is one of the core technologies of the dynamic execution architecture of modern CPUs (Central Processing Units). It predicts the direction of branch instructions in the program in advance, avoiding long pauses in the processor pipeline due to waiting for the calculation results of branch conditions. It is a key foundational technology supporting modern high-performance processors.
[0003] However, predicting the jump address of indirect jump instructions is quite difficult in processor branch prediction. This is because the jump address of indirect jump instructions often depends on the value of the register file, making it difficult to predict accurately.
[0004] Current branch jump address prediction systems are imperfect, resulting in low accuracy and reliability of prediction results. Therefore, developing a branch jump address prediction system that can accurately and reliably predict branch jump addresses has become an urgent problem to solve. Summary of the Invention
[0005] This disclosure addresses some of the shortcomings mentioned in the background art by providing a branch jump address prediction system and method.
[0006] In a first aspect, embodiments of this disclosure provide a branch jump address prediction system, comprising: a fetch branch prediction module including a branch target cache (BTB) submodule, and an instruction execution module for executing store instructions, wherein the BTB submodule and the instruction execution module are connected via a target data path; wherein the instruction execution module is configured to execute store instructions, generate a store instruction write request in response to detecting that a store instruction write request generation condition is met, and send the store instruction write request to the BTB submodule via the target data path; the fetch branch prediction module is configured to receive the store instruction write request through the BTB submodule, and write the store data carried in the store instruction write request into the BTB submodule according to the store instruction write request, so as to predict the branch jump address based on the store data.
[0007] In a second aspect, embodiments of this disclosure provide a branch jump address prediction method applicable to a branch jump address prediction system. The branch jump address prediction system includes: a fetch branch prediction module including a branch target cache (BTB) submodule, and an instruction execution module for executing store instructions. The BTB submodule and the instruction execution module are connected via a target data path. The method includes the following steps: executing a store instruction; in response to detecting that a store instruction write request generation condition is met, generating a store instruction write request and sending the store instruction write request to the BTB submodule via the target data path; receiving the store instruction write request through the BTB submodule; and writing the store data carried in the store instruction write request into the BTB submodule according to the store instruction write request, so as to predict the branch jump address based on the store data.
[0008] In a third aspect, embodiments of this disclosure provide an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, it implements the method described in the second aspect.
[0009] In a fourth aspect, embodiments of this disclosure provide a processor-readable storage medium storing a computer program for causing a processor to perform the method described in the second aspect.
[0010] In a fifth aspect, embodiments of this disclosure provide a computer program product including a computer program that, when executed by a processor, implements the method described in the second aspect.
[0011] The embodiments provided in this disclosure have at least the following beneficial technical effects: A branch jump address prediction system according to an embodiment of this disclosure includes an instruction fetch branch prediction module including a branch target cache (BTB) submodule, and an instruction execution module for executing store instructions. The BTB submodule and the instruction execution module are connected via a target data path. The instruction execution module executes the store instruction, generates a store instruction write request in response to detecting that a store instruction write request generation condition is met, and sends the store instruction write request to the BTB submodule via the target data path. Further, the instruction fetch branch prediction module receives the store instruction write request through the BTB submodule and, based on the store instruction write request, writes the store data carried in the store instruction write request into the BTB submodule to predict the branch jump address based on the store data. This embodiment of the disclosure, based on prediction based on historical jump addresses, adds a BTB write mechanism and, through the target data path, enables the store instruction to directly write the jump address into the BTB, improving the accuracy and reliability of the branch jump address prediction results and enhancing program performance.
[0012] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description
[0013] The accompanying drawings are provided to better understand this solution and do not constitute a limitation of this disclosure. Wherein: Figure 1 This is a schematic diagram of a branch jump address prediction system; Figure 2 This is a schematic diagram of another branch jump address prediction system; Figure 3 This is a schematic diagram of the instruction execution module's processing procedure; Figure 4 This is a schematic diagram of a BTB address mapping method applicable to BTB; Figure 5 This is a schematic diagram of a RISC V program; Figure 6 This is a flowchart illustrating a branch jump address prediction method; Figure 7 It is a block diagram of an electronic device.
[0014] In the picture: 1000 - Branch jump address prediction system; 100 - Instruction fetch branch prediction module; 200 - Instruction execution module; 300 - Target data path; 101 - BTB submodule. Detailed Implementation
[0015] The present disclosure will now be described in further detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present disclosure and not intended to limit it. Furthermore, it should be noted that, for ease of description, only the parts relevant to the present disclosure are shown in the drawings, not the entire structure.
[0016] It should be noted that high-performance processors typically use branch prediction combined with speculative execution to improve program performance. That is, when a branch instruction is fetched, the jump address (and jump direction) of the instruction is predicted in advance. Then, before obtaining the jump result, the instruction is fetched and executed in advance based on the predicted jump address, thereby reducing cavitation in the processor pipeline caused by waiting for the branch jump result.
[0017] However, if a prediction error is discovered after obtaining the actual jump result, the prematurely executed program segment must be discarded, the pipeline must be flushed, and instruction fetching and execution must restart from the correct address. This results in a loss of performance and power consumption.
[0018] In existing technologies, the Branch Target Buffer (BTB) is often considered the core of modern CPU branch prediction systems. The BTB refers to a common circuit structure used for predicting branch jump addresses, storing the historical jump addresses of branch instructions. The processor typically uses the records in the BTB as the predicted jump address for the currently fetched branch instruction, combining this information with the branch direction prediction result for subsequent instruction fetching.
[0019] Traditional methods typically write the jump results of the branch instructions that have already been fetched into the BTB for subsequent predictions; however, traditional methods often have many drawbacks.
[0020] For example, when a branch instruction is not recorded in the BTB, its jump address cannot be obtained, making accurate prediction impossible. This usually happens when an instruction is executed for the first time, or when it is overwritten by an address alias.
[0021] To address this situation, several solutions exist. Optionally, the problem can be alleviated by increasing the capacity of the BTB and using hashing for addresses. Alternatively, it can be alleviated by introducing a branch instruction frequency item and storing different types of branch instructions in different BTBs.
[0022] For example, for indirect jump instructions, their jump address is based on the value of certain registers, and when the value of the registers changes, the next prediction will fail.
[0023] There is currently no good solution to this problem. Therefore, there is no branch jump address prediction system that can simultaneously resolve the aforementioned defects caused by writing the jump results of already fetched branch instructions into the BTB for subsequent prediction.
[0024] Therefore, this disclosure proposes a branch jump address prediction system. Based on prediction based on historical jump addresses, a BTB writing mechanism is added. Through the target data path, the store instruction can directly write the jump address into the BTB, which improves the accuracy and reliability of branch jump address prediction results and improves program performance.
[0025] Figure 1 This is a schematic diagram of a branch jump address prediction system according to the present disclosure.
[0026] like Figure 1 As shown, the branch jump address prediction system 1000 includes an instruction fetch branch prediction module 100, an instruction execution module 200, and a target data path 300. The instruction fetch branch prediction module 100 includes a branch target cache (BTB) submodule 101, and the instruction execution module 200 is used to execute at least the store instruction. The BTB submodule 101 and the instruction execution module 200 are connected through the target data path 300.
[0027] The instruction execution module 200 is used to execute store instructions. In response to detecting that the conditions for generating a store instruction write request are met, it generates a store instruction write request and sends the store instruction write request to the BTB submodule 101 through the target data path 300.
[0028] The instruction fetching branch prediction module 100 is used to receive store instruction write requests through the BTB submodule 101, and write the store data carried in the store instruction write request into the BTB submodule 101 according to the store instruction write request, so as to predict the branch jump address according to the store data.
[0029] From a circuit design perspective, the branch jump address prediction system 1000 proposed in this disclosure includes the storage space of BTB in the memory address space and adds a target data path 300, thereby realizing the function of writing the store instruction into BTB.
[0030] In accordance with the general architecture of a processor, the BTB submodule 101 belongs to the front-end instruction fetch / branch prediction part.
[0031] It should be noted that this disclosure does not limit the specific structure of the BTB submodule 101, and it can be set according to the actual situation.
[0032] As one possible implementation, BTB submodule 101 can adopt a set-associative cache structure.
[0033] Furthermore, from a software control perspective, the branch jump address prediction system 1000 proposed in this disclosure utilizes store-type instructions, which are typically supported by general processors, to write jump addresses into the BTB. In this way, the application can flexibly insert store instructions before branch instructions as needed, pre-writing the jump addresses of subsequent branch instructions into the BTB.
[0034] The store instruction is a RISC V instruction set used to write data into memory; the application correspondingly adds a store instruction for a specific memory access address (BTB address) to invoke this function.
[0035] In this embodiment of the disclosure, when the instruction execution module 200 executes the store instruction, it can identify whether the conditions for generating a store instruction write request are met based on the store instruction, and generate the corresponding identification result.
[0036] In response to the detection (identification result) that the conditions for generating a store instruction write request are met, a store instruction write request can be generated and sent to the BTB submodule 101 via the target data path 300. Accordingly, the instruction fetch branch prediction module 100 can receive the store instruction write request through the BTB submodule 101 and, based on the store instruction write request, write the store data carried in the store instruction write request into the target BTB table entry of the BTB submodule 101 to predict the branch jump address based on the store data.
[0037] If the detection (identification result) indicates that the conditions for generating a write request for the store instruction are not met, other corresponding operations such as memory access can be performed.
[0038] The store instruction write request includes at least store data and address information. The address information can be used to determine the specific location where the store data will be written.
[0039] After predicting branch jump addresses based on store data, the instruction fetch branch prediction module 100 can send the valid instruction stream, filtered by branch prediction and pre-fetched, into the subsequent processor pipeline. The processor pipeline can process the pre-fetched instruction sequence from the instruction fetch branch prediction module 100 and send the processed decoded and scheduled load (read memory) and store (write memory) type memory access instructions to the downstream instruction execution module 200.
[0040] A branch jump address prediction system according to an embodiment of this disclosure includes an instruction fetch branch prediction module including a branch target cache (BTB) submodule, and an instruction execution module for executing store instructions. The BTB submodule and the instruction execution module are connected via a target data path. The instruction execution module executes the store instruction, generates a store instruction write request in response to detecting that a store instruction write request generation condition is met, and sends the store instruction write request to the BTB submodule via the target data path. Further, the instruction fetch branch prediction module receives the store instruction write request through the BTB submodule and, based on the store instruction write request, writes the store data carried in the store instruction write request into the BTB submodule to predict the branch jump address based on the store data. This embodiment of the disclosure, based on prediction based on historical jump addresses, adds a BTB write mechanism and, through the target data path, enables the store instruction to directly write the jump address into the BTB, improving the accuracy and reliability of the branch jump address prediction results and enhancing program performance.
[0041] It should be noted that before using the store instruction to write to the BTB, the address corresponding to the BTB to be written to must first be determined. In other words, after executing the store instruction, the instruction execution module 200 can identify the store address corresponding to the store instruction.
[0042] To explain the above process more clearly, we will first briefly explain the BTB address mapping method applicable to BTB.
[0043] like Figure 2 As shown, taking a basic BTB address mapping method applicable to 2-way 8-group BTB as an example, the simplest way to divide the BTB address is to directly allocate a continuous address range from addr0 to 15 as the BTB address range. However, discrete address ranges are theoretically also feasible, such as dividing addr0-7 and addr16-23 as BTB address ranges. There are also more complex BTB mapping methods, such as those using hashing. Regardless of the address mapping method, one address can be selected from all addresses corresponding to each row as the BTB address for that row, ensuring that the BTB addresses of all rows are unique. This constitutes a complete, precise BTB address range.
[0044] The following explanation, in conjunction with an embodiment, illustrates the process following the execution of the store instruction by the instruction execution module 200.
[0045] In this disclosure, after executing the store instruction, the instruction execution module 200 is further configured to: obtain the store address corresponding to the store instruction and the target BTB address range. The identification result of whether the store address is within the target BTB address range can be used as the basis for determining whether the conditions for generating a store instruction write request are met.
[0046] like Figure 3 As shown, if the store address is within the target BTB address range, the conditions for generating a store instruction write request are confirmed; if the store address is not within the target BTB address range, a memory access operation is performed.
[0047] In this embodiment of the disclosure, when executing a store instruction, after calculating the address of the store instruction, it can be determined whether a BTB write operation needs to be performed based on the defined target BTB address range. If the store address falls within the target BTB address range, the BTB write operation is performed. In this case, a memory access operation is not required because memory access operations often take a long time, which affects processor performance; therefore, the memory access operation is not performed. If the store address is not within the target BTB address range, a normal memory access operation is performed.
[0048] Furthermore, such as Figure 4 As shown, BTB itself has other update methods. Therefore, when a store command write request to BTB (store command write request) conflicts with other write requests, arbitration is required.
[0049] In this disclosure, after receiving a store instruction write request, the instruction fetching branch prediction module 100 is further configured to: in response to detecting a conflict between the store instruction write request and other write requests, obtain a target arbitration strategy, and arbitrate the store instruction write request and other write requests according to the target arbitration strategy.
[0050] It should be noted that this disclosure does not limit the specific settings of the target arbitration strategy, which can be set according to the actual situation.
[0051] Optionally, considering that the jump addresses written by the store instruction can be considered correct, the store instruction can be written with the highest priority. Optionally, polling or other custom arbitration methods can be used as appropriate.
[0052] In this disclosure, the instruction execution module 200 can execute not only the store instruction but also the load instruction.
[0053] In this case, the instruction execution module 200 is also used to: execute the load instruction and initiate exception handling in response to the detection that the exception handling conditions are met.
[0054] In this disclosure, after executing the load instruction, the instruction execution module 200 is further configured to: obtain the load address corresponding to the load instruction and the target BTB address range. The identification result of whether the load address is within the target BTB address range can be used as the basis for determining whether the exception handling conditions are met.
[0055] like Figure 3 As shown, if the load address is within the target BTB address range, the exception handling condition is confirmed; if the load address is not within the target BTB address range, a memory access operation is performed.
[0056] In this embodiment, since the processor corresponding to the branch jump address prediction system 1000 no longer uses the store instruction to store the BTB address range in memory, this part of the memory space can be directly ignored as a precaution. When the load address also falls within the target BTB address range, it is considered an illegal address, and the processor initiates exception handling according to the normal process.
[0057] It should be noted that a single line of data in a BTB typically includes a tag indicating the branch instruction location, the target jump address (addr), and some custom items such as the branch instruction type. The typical amount of data that a store instruction can carry at one time corresponds to 32 / 64 bits on a 32 / 64-bit system.
[0058] If the information carried by a single BTB line exceeds the data size of the store command, then the write operation needs to be performed multiple times.
[0059] Therefore, this disclosure defines at least two write types, and the write process of the instruction fetch branch prediction module 100 is explained below with reference to the embodiments.
[0060] In this disclosure, the instruction fetching and branch prediction module 100 is further configured to: obtain a first data volume of row-carrying information of the target BTB table entry of the BTB submodule 101, and a second data volume of the store instruction write request. Further, a target write strategy can be obtained based on the first and second data volumes, and the store data carried in the store instruction write request can be written to the row of the target BTB table entry of the BTB submodule 101 according to the target write strategy.
[0061] It should be noted that this disclosure does not limit the specific settings of the target write strategy, which can be set according to the actual situation.
[0062] As one possible implementation, the target write strategy can be set to include at least a single write and two writes.
[0063] The target write strategy is a single write. The fetch branch prediction module 100 is also used to: write the store data into the row of the target BTB table entry at once, and set the valid signal of the row to 1 through the BTB submodule 101.
[0064] In the case of a single write, the amount of data carried by the store instruction can cover the information of a line in BTB. Thus, the store data can be written to the corresponding position of a line in BTB at once, and BTB sets the valid signal of that line to 1.
[0065] The target write strategy involves two writes. The instruction fetch branch prediction module 100 is also used to: extract target bit data from the store data as the number of the BTB data segment indicating the BTB entry to be written. Furthermore, the target write order can be obtained, and other bit data from the store data can be written to the row of the target BTB entry in two separate writes according to the target write order. The valid signal of the row during the two writes is set to 0 and 1 respectively by the BTB submodule 101.
[0066] Before extracting the target bit data from the store data as the number of the BTB data segment to be written to the BTB table entry, the instruction fetch branch prediction module 100 is further configured to: divide the data of the row of the target BTB table entry into two segments.
[0067] In the two-write scenario, a row of data in the BTB is divided into two segments, each of which can be overwritten by a single store instruction. Specifically, the length of the BTB segment is shorter than the length of the store instruction. One bit is extracted from the store instruction as the number of the BTB segment to be written, and the remaining bits represent the data to be written. During the actual write operation, data is written to the BTB row in two separate steps in a fixed order. The valid signal for that row is set to 0 during the first write and set to 1 during the second write. The write method can be selected based on the actual BTB row size of the processor and the amount of data carried by the store instruction.
[0068] The following section uses a simple RISC V program as an example to explain part of the processing of the branch jump address prediction system 1000 proposed in this disclosure.
[0069] like Figure 5As shown, the jump target address of the `jr` instruction in the program depends on the value of register `t0`, but this value is modified to `imm` by the `addi` instruction before the `jr` instruction, meaning that address prediction will fail. To ensure that the jump address of the `jr` instruction can be correctly predicted, an `sw` instruction can be inserted after the `addi` instruction and before the `jr` instruction. This instruction stores the jump address corresponding to the modified value of register `t0` into the BTB line corresponding to the `jr` instruction. The multiple `nop` instructions after `sw` ensure that the `sw` instruction has completed execution and written the jump address to the BTB before the `jr` instruction is fetched. In practical applications, these `nop` instructions can be replaced with useful program segments (but will not modify `t0`).
[0070] Therefore, although writing to the BTB in advance adds three instructions (addi, lui, sw), it is less than the loss caused by address prediction failure. Especially for multi-fetch / multi-issue processors with deep pipelines, the number of instructions washed away by branch prediction failure may be a dozen or more. Therefore, the branch jump address prediction system 1000 proposed in this disclosure uses the method of writing to the BTB in advance. It can flexibly insert store instructions before the branch instructions as needed, and write the jump address of the subsequent branch instructions to the BTB in advance, so that the program can obtain better performance.
[0071] Figure 6 This is a flowchart illustrating a branch jump address prediction method provided in an embodiment of this disclosure. The branch jump address prediction method is applicable to a branch jump address prediction system 1000, which includes an instruction fetch branch prediction module 100, an instruction execution module 200, and a target data path 300. The instruction fetch branch prediction module 100 includes a branch target cache (BTB) submodule 101, and the instruction execution module 200 is used to execute at least store instructions. The BTB submodule 101 and the instruction execution module 200 are connected via the target data path 300.
[0072] As one possible implementation, such as Figure 6 As shown, the specific steps include: S601. Execute the store instruction. In response to the detection that the conditions for generating a store instruction write request are met, generate a store instruction write request and send the store instruction write request to the BTB submodule through the target data path.
[0073] S602. Receive the store instruction write request through the BTB submodule, and write the store data carried in the store instruction write request into the BTB submodule according to the store instruction write request, so as to predict the branch jump address based on the store data.
[0074] In this disclosure, when performing branch jump address prediction, the instruction execution module 200 can execute the store instruction, identify whether the store instruction write request generation conditions are met based on the store instruction, and generate the corresponding identification result.
[0075] In response to the detection that the conditions for generating a store instruction write request are met, a store instruction write request can be generated and sent to the BTB submodule 101 via the target data path 300. Accordingly, the instruction fetch branch prediction module 100 can receive the store instruction write request through the BTB submodule 101, and write the store data carried in the store instruction write request into the target BTB table entry of the BTB submodule 101, so as to predict the branch jump address based on the store data.
[0076] If the conditions for generating a write request for a store directive are not met, other corresponding operations such as memory access can be performed.
[0077] It should be noted that the process of identifying whether the conditions for generating a write request according to the store instruction are met and generating the corresponding identification result is equivalent to determining the operation corresponding to the address to be written to the BTB.
[0078] As one possible implementation, after executing the store instruction, the instruction execution module 200 is also used to: obtain the store address corresponding to the store instruction and the target BTB address range. The identification result of whether the store address is within the target BTB address range can be used as the basis for judging whether the conditions for generating a store instruction write request are met.
[0079] In response to the store address being within the target BTB address range, the conditions for generating a store instruction write request are confirmed to be met.
[0080] If the store address is not within the range of the target BTB address, it is confirmed that the conditions for generating a store instruction write request are not met, and a memory access operation is performed.
[0081] Furthermore, the instruction fetch branch prediction module 100 can receive the store instruction write request through the BTB submodule 101, and write the store data carried in the store instruction write request into the BTB submodule 101 according to the store instruction write request, so as to predict the branch jump address according to the store data.
[0082] It should be noted that BTB itself has other update methods. Therefore, when a store command write request to BTB (store command write request) conflicts with other write requests, arbitration is required.
[0083] As one possible implementation, after receiving a store instruction write request, the instruction fetching and branch prediction module 100 is further configured to: in response to detecting a conflict between the store instruction write request and other write requests, obtain a target arbitration strategy, and arbitrate the store instruction write request and other write requests according to the target arbitration strategy.
[0084] It should also be noted that if the information carried by a single BTB line exceeds the data size of the store command, then the write operation needs to be performed in multiple steps.
[0085] As one possible implementation, the instruction fetching prediction module 100 can obtain a first data volume of row-carrying information of the target BTB table entry of the BTB submodule 101, and a second data volume of the store instruction write request. Further, based on the first and second data volumes, a target write strategy can be obtained, and according to the target write strategy, the store data carried in the store instruction write request can be written to the row of the target BTB table entry of the BTB submodule 101.
[0086] If the target write strategy is a single write, the instruction fetch branch prediction module 100 can write the store data into the row of the target BTB table entry at once, and set the row's valid signal to 1 through the BTB submodule 101.
[0087] If the target write strategy is a two-write operation, the instruction fetch branch prediction module 100 can first divide the data of the target BTB entry row into two segments, each of which can be overwritten by a single piece of store data, specifically, the BTB data segment length is less than the store data length. Then, the target bit data is extracted from the store data as the number of the BTB data segment indicating the BTB entry to be written. Furthermore, the target write order can be obtained, and the other bits of the store data are written to the target BTB entry row twice according to the target write order. The BTB submodule 101 then sets the row's valid signal to 0 and 1 respectively during the two writes.
[0088] In this disclosure, the instruction execution module 200 can execute not only the store instruction but also the load instruction.
[0089] In this case, the instruction execution module 200 can also execute the load instruction to initiate exception handling in response to the detection that the exception handling conditions are met.
[0090] In this disclosure, after executing the load instruction, the instruction execution module 200 can obtain the load address corresponding to the load instruction and the target BTB address range. The identification result of whether the load address is within the target BTB address range can be used as the basis for judging whether the exception handling conditions are met.
[0091] In response to the load address being within the target BTB address range, it is confirmed that the exception handling conditions are met.
[0092] In response to the load address not being within the target BTB address range, it is confirmed that the exception handling conditions are not met, and a memory access operation is performed.
[0093] Furthermore, after predicting the branch jump address based on the store data, the instruction fetch branch prediction module 100 can send the valid instruction stream, filtered by branch prediction and pre-fetched, into the subsequent processor pipeline. The processor pipeline can process the pre-fetched instruction sequence from the instruction fetch branch prediction module 100, and send the processed decoded and scheduled load (read memory) and store (write memory) type memory access instructions to the downstream instruction execution module 200.
[0094] According to an embodiment of this disclosure, a branch jump address prediction method can execute a store instruction through an instruction execution module. In response to detecting that the conditions for generating a store instruction write request are met, a store instruction write request is generated and sent to the BTB submodule via a target data path. Further, the instruction fetch branch prediction module receives the store instruction write request through the BTB submodule and, based on the store instruction write request, writes the store data carried in the store instruction write request into the BTB submodule to predict the branch jump address based on the store data. This embodiment of the disclosure, based on prediction based on historical jump addresses, adds a BTB writing mechanism and, through a target data path, enables the store instruction to directly write the jump address into the BTB, improving the accuracy and reliability of the branch jump address prediction results and enhancing program performance.
[0095] According to embodiments of this disclosure, this disclosure also provides an electronic device 4000, such as... Figure 7 As shown, it includes a memory 500, a processor 600, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the aforementioned branch jump address prediction method.
[0096] According to embodiments of this disclosure, a processor-readable storage medium is also provided. This processor-readable storage medium stores a computer program that causes the processor to execute the aforementioned branch jump address prediction method.
[0097] The processor-readable storage medium can be any available medium or data storage device that the processor can access, including but not limited to magnetic memory (e.g., floppy disk, hard disk, magnetic tape, magneto-optical disk (MO)), optical memory (e.g., CD, DVD, BD, HVD), and semiconductor memory (e.g., ROM, EPROM, EEPROM, non-volatile memory (NAND FLASH), solid-state drive (SSD)).
[0098] According to embodiments of this disclosure, this disclosure also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, performs the aforementioned branch jump address prediction method.
[0099] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this disclosure can be achieved, and this is not limited herein.
[0100] The specific embodiments described above do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure should be included within the scope of protection of this disclosure.
Claims
1. A branch jump address prediction system, characterized in that, include: The system includes a branch prediction module for the branch target cache (BTB) submodule and an instruction execution module for executing store instructions. The BTB submodule and the instruction execution module are connected via a target data path. The instruction execution module is used to execute the store instruction, generate a store instruction write request in response to detecting that the store instruction write request generation conditions are met, and send the store instruction write request to the BTB submodule through the target data path; The instruction fetching branch prediction module is used to receive the store instruction write request through the BTB submodule, and write the store data carried in the store instruction write request into the BTB submodule according to the store instruction write request, so as to predict the branch jump address based on the store data.
2. The system according to claim 1, characterized in that, After executing the store instruction, the instruction execution module is further configured to: Obtain the store address corresponding to the store instruction, and the target BTB address range; In response to the store address being within the range of the target BTB address, it is confirmed that the conditions for generating the store instruction write request are met.
3. The system according to claim 2, characterized in that, The instruction execution module is further configured to: In response to the store address not being within the range of the target BTB address, a memory access operation is performed.
4. The system according to claim 1, characterized in that, After receiving the store instruction write request through the BTB submodule, the instruction fetch branch prediction module is further configured to: In response to the detection that the store instruction write request conflicts with other write requests, a target arbitration policy is obtained, and the store instruction write request and the other write requests are arbitrated according to the target arbitration policy.
5. The system according to claim 1, characterized in that, The instruction execution module is further configured to execute load instructions, and the instruction execution module is further configured to: Execute the load instruction and, in response to the detection that the exception handling conditions are met, initiate exception handling.
6. The system according to claim 5, characterized in that, After executing the load instruction, the instruction execution module is further configured to: Obtain the load address corresponding to the load instruction, and the target BTB address range; In response to the load address being within the range of the target BTB address, the exception handling condition is confirmed to be met.
7. The system according to claim 1, characterized in that, The instruction fetching branch prediction module is also used for: Obtain the first data volume of row-carrying information of the target BTB table entry of the BTB submodule, and the second data volume of the store instruction write request; Based on the first data volume and the second data volume, obtain the target write strategy; According to the target write strategy, the store data carried in the store instruction write request is written to the row of the target BTB table entry of the BTB submodule.
8. The system according to claim 7, characterized in that, The target write strategy is a single write, and the instruction fetch branch prediction module is further used for: The store data is written to the row of the target BTB table entry in one go, and the valid signal of the row is set to 1 by the BTB submodule.
9. The system according to claim 7, characterized in that, The target write strategy is a two-write operation, and the instruction fetch branch prediction module is further used for: Extract the target bit data from the store data as the number of the BTB data segment to indicate the BTB entry to be written; Obtain the target write order, and write the other bits of data in the store data into the row of the target BTB table entry in two separate writes according to the target write order. Then, set the valid signal of the row to 0 and 1 respectively during the two writes through the BTB submodule.
10. A method for predicting branch jump addresses, characterized in that, A branch jump address prediction system is applicable to the branch jump address prediction system, which includes: an instruction fetch branch prediction module including a branch target cache (BTB) submodule, and an instruction execution module for executing store instructions, wherein the BTB submodule and the instruction execution module are connected through a target data path; The method includes the following steps: Execute the store instruction, and in response to detecting that the store instruction write request generation conditions are met, generate a store instruction write request, and send the store instruction write request to the BTB submodule through the target data path; The BTB submodule receives the store instruction write request and writes the store data carried in the store instruction write request into the BTB submodule to predict the branch jump address based on the store data.
