Out-of-order execution pipeline control method, apparatus and out-of-order execution processor

By performing feature tracing and bypass caching on alternative paths in the out-of-order execution processor, the pipeline stall problem caused by branch prediction errors is solved, achieving fast recovery and efficient instruction processing, while reducing resource waste and power consumption.

CN123114552APending Publication Date: 2026-11-17T-HEAD (SHANGHAI) SEMICON CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611033562.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-10
Publication Date
2026-11-17

AI Technical Summary

Technical Problem

In out-of-order execution processors, branch prediction errors cause pipeline stalls and performance losses. Existing technical solutions suffer from resource waste and power consumption issues, and cannot effectively shorten the recovery delay of branch prediction errors.

Method used

By performing feature tracking on alternative paths and recording the instruction sequence feature information of alternative paths, the instruction sequence sent by the instruction fetch unit to the decoder is cached during the instruction fetch process through bypass detection. If a branch prediction error occurs, the instruction sequence is directly injected into the decoder, avoiding additional instruction cache read requests and reducing the impact on the main path.

Benefits of technology

It significantly reduces the recovery latency after branch prediction errors, avoids additional occupation of instruction cache read ports, maintains normal instruction fetch bandwidth of the main path, and reduces resource waste and power consumption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123114552A_ABST
    Figure CN123114552A_ABST
Patent Text Reader

Abstract

This invention discloses an out-of-order execution pipeline control method, apparatus, and out-of-order execution processor. In this embodiment, the target branch instructions of alternative paths are traced by feature tracking, and the feature information of the instruction sequence of the alternative paths is recorded. During instruction fetching, when the current path corresponds to a branch path corresponding to a data item in the unpredictable branch record, at least a portion of the instruction sequence sent by the instruction fetch unit to the decoder is cached using a bypass detection method based on the feature information corresponding to that data item. If a branch prediction error subsequently occurs, and the alternative path for the branch jump has been cached, the instruction sequence corresponding to the data item is injected into the decoder. Therefore, the recovery delay is significantly shortened after a branch prediction error occurs, and zero additional read requests are made to the instruction cache read port during the entire backup instruction reserve process, without affecting the normal instruction fetch bandwidth of the main path.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of high-performance processor design, and more specifically to an out-of-order execution pipeline control method, apparatus, and out-of-order execution processor. Background Technology

[0002] In out-of-order execution processors, branch prediction errors are one of the main causes of pipeline stalls and performance degradation. Current processors typically employ deep pipelines of 15 to 20 stages to improve clock frequency and instruction throughput. When the branch predictor makes an incorrect prediction about the jump direction of a conditional branch instruction (hereinafter referred to as a branch instruction), the processor needs to flush all instructions fetched, decoded, and executed along the incorrect path in the pipeline. It then fetches instructions again from the opposite direction of the branch instruction jump at the front end, fetches instructions from the correct jump address, and waits for these new instructions to flow through the fetch, decode, and rename pipeline stages before finally reaching the execution unit. In this process, the number of cycles required for the front end to re-fetch and fill the pipeline constitutes the main component of the total penalty for branch prediction errors. In deep pipelined processors, this penalty can reach 15 to 30 clock cycles, directly reducing the number of instructions executed per cycle.

[0003] To shorten the recovery latency of branch prediction errors, existing technologies have proposed different microarchitecture schemes for optimization. One scheme is alternating path fetching. When the processor front end encounters a branch instruction with low confidence, the fetch unit simultaneously sends two read requests to the instruction cache, fetching and decoding instructions in both the jump and non-jump directions. The drawback of this scheme is that the read ports of the instruction cache and the throughput of the decoder are fixed physical resources. Alternating path fetching divides the front end bandwidth in two, halving the execution speed of the main path. Furthermore, one of the two paths will eventually be discarded, consuming significant dynamic power. Another scheme is the misprediction recovery buffer. A small buffer is set up in the front end. When a low-confidence branch is encountered, instructions from alternative paths are proactively fetched and stored in the buffer in advance. If the prediction fails, the instructions are directly injected into the pipeline from the buffer. The drawback of this scheme is that the buffer still requires the front end to actively send additional read requests to the instruction cache to read alternative paths, which also interferes with the main fetch flow. In practice, this scheme often caches a large number of path instructions that will not actually cause errors, resulting in poor buffer hit rate and area utilization. Another approach is a micro-operation cache or trace cache, which caches the decoded micro-operations or consecutive instruction traces. When the same hot path is executed again, the data is directly fed from the cache, bypassing the instruction fetch and decode sections. This approach is designed to speed up the main path, rather than to handle branch prediction errors. When branch prediction fails and the program moves to a less popular alternative path, a cache miss usually occurs, and the system still needs to fall back to the instruction cache to fetch the instruction again. If the alternative path is forcibly stuffed into this cache, it will push out the hot code on the main path, causing cache thrashing. Summary of the Invention

[0004] In view of this, embodiments of this application provide an out-of-order execution pipeline control method, apparatus, and out-of-order execution processor, aiming to further optimize pipeline control and recovery in the event of branch prediction errors.

[0005] Firstly, a method for controlling out-of-order execution pipelines is provided, the method comprising: Identify the target branch instruction for which feature tracking of alternative paths is required, and record the feature information of the instruction sequence of the alternative paths of the target branch instruction. The alternative paths are the paths through which the target branch instruction jumps again after a branch prediction error. Get the current instruction fetch address of the instruction fetch unit; In response to the current fetch address matching the alternative path jump address of at least one data item in the unpredictable branch record, and the previous fetch address of the current fetch address matching the address of the branch instruction of the data item, at least a portion of the instruction sequence sent by the fetch unit to the decoder is cached by bypass detection based on the feature information of the instruction sequence of the alternative path corresponding to the matched data item. In response to receiving a broadcast signal indicating a branch prediction error, the address of the erroneous branch instruction and the actual jump target address carried in the broadcast signal are matched with the address of the branch instruction and the alternative path jump address in the data item of the unpredictable branch record, respectively. In response to the discovery of a data item that matches both the address of the branch instruction and the jump address of the alternative path, and the completion of the caching operation of the instruction sequence corresponding to the data item, the instruction sequence corresponding to the data item is injected into the decoder segment.

[0006] In some implementations, the target branch instructions that require caching operations include: In response to a branch prediction error, the unpredictable branch record is updated based on the branch instruction commit information provided by the commit segment. The unpredictable branch record includes multiple data items, each of which includes at least the address of the corresponding branch instruction, the address of the corresponding alternative path jump, and the count of the branch instruction prediction error. In response to the count in the data item of the unpredictable branch record reaching a first threshold when updating the data item, the branch instruction of the data item is taken as the target branch instruction.

[0007] In some implementations, the characteristic information of the instruction sequence of the candidate path is an offset mapping, which records the sequence of address offsets between adjacent instructions in the instruction sequence of the candidate path.

[0008] In some implementations, at least a portion of the instruction sequence sent from the instruction fetch unit to the decode segment is buffered via bypass detection, including: The address offset between adjacent instructions sent by the instruction fetch unit to the decode segment is compared with the offset at the corresponding position in the offset mapping; In response to a match, cache the current instruction; In response to a discrepancy, the caching operation is completed and the trajectory end address is updated to the current fetch address.

[0009] In some implementations, injecting the instruction sequence corresponding to the data item into the decoder segment includes: Send a pause signal to the instruction fetch unit to prevent it from making a new instruction fetch request to the instruction cache; Send the cached sequence of instructions for the alternative paths to the decoder segment; The updated trajectory end address is sent as the new instruction fetch address to the instruction fetch unit to resume operation of the instruction fetch unit.

[0010] In some implementations, updating unpredictable branch records includes: Based on the address of the target branch instruction and the alternative path jump address of the target branch instruction, query the matching data item in the unpredictable branch record; In response to finding a matching data item, update the count of the matching data items; In response to finding a partially matching data item, the address of the target branch instruction and the alternative path jump address of the target branch instruction are recorded in an allocated data item, and the corresponding count is initialized; wherein, the partially matching data item is a data item in which the address of the branch instruction matches the address of the target branch instruction, but the alternative path jump address does not match the alternative path jump address of the target branch instruction.

[0011] In some implementations, the unpredictable branch record has a predetermined number of data items; The address of the target branch instruction and the alternative path jump address of the target branch instruction are recorded in an allocated data item, including: In response to the existence of a free data item, a free data item is allocated, and the address of the target branch instruction and the alternative path jump address of the target branch instruction are recorded in the free data item; In response to the absence of a free data item, a low-count data item is cleared and allocated to the target branch instruction, and the address of the target branch instruction and the alternative path jump address of the target branch instruction are recorded in the allocated data item.

[0012] In some implementations, the instructions in the cached instruction sequence are the raw, undecoded instructions.

[0013] In some implementations, the data items for unpredictable branch records also include branch mappings, which record the jump direction information of each branch instruction within the alternative path; The method further includes: The branch history register of the branch predictor is incrementally updated according to the branch mapping.

[0014] Secondly, an out-of-order execution pipeline control device is provided, the device comprising a difficult-to-predict branch record unit and an instruction sequence buffer; The unpredictable branch record unit is configured as follows: Identify the target branch instruction for which feature tracking of alternative paths is required, and record the feature information of the instruction sequence of the alternative paths for the target branch instruction. The alternative paths are the paths through which the target branch instruction re-jumps after a branch prediction error. In response to receiving a broadcast signal indicating a branch prediction error, the address of the erroneous branch instruction and the actual jump target address carried in the broadcast signal are matched with the address of the branch instruction and the alternative path jump address in the data item of the unpredictable branch record, respectively. The instruction sequence buffer is configured as follows: Get the current instruction fetch address of the instruction fetch unit; In response to the current fetch address matching the jump address of at least one data item in the unpredictable branch record, and the previous fetch address matching the address of the branch instruction of the data item, based on the feature information of the instruction sequence of the candidate path corresponding to the matched data item, at least a portion of the instruction sequence sent by the fetch unit to the decoder is cached through bypass detection; and In response to the unpredictable branch record unit finding a data item whose address matches both the branch instruction address and the alternative path jump address, and the completion of the caching operation of the instruction sequence corresponding to the data item, the instruction sequence corresponding to the data item is injected into the decoder segment.

[0015] In some implementations, the unpredictable branch record unit is configured as follows: In response to a branch prediction error, the unpredictable branch record is updated based on the branch instruction commit information provided by the commit segment. The unpredictable branch record includes multiple data items, each of which includes at least the address of the corresponding branch instruction, the address of the corresponding alternative path jump, and the count of the branch instruction prediction error. In response to the count in the data item of the unpredictable branch record reaching a first threshold when updating the data item, the branch instruction of the data item is taken as the target branch instruction.

[0016] In some implementations, the characteristic information of the instruction sequence of the alternative path corresponding to the branch instruction is an offset mapping, which records the address offset sequence between adjacent instructions in the instruction sequence of the alternative path.

[0017] In some implementations, the instruction sequence buffer is configured as follows: The address offset between adjacent instructions sent by the instruction fetch unit to the decode segment is compared with the offset at the corresponding position in the offset mapping; In response to a match, cache the current instruction; In response to a discrepancy, the caching operation is completed and the trajectory end address is updated to the current fetch address.

[0018] In some implementations, the instruction sequence buffer is configured as follows: In response to the unpredictable branch record unit finding a data item that matches both the address of the branch instruction and the jump address of the alternative path, and completing the caching operation of the alternative path instruction sequence, a pause signal is sent to the instruction fetch unit to prevent the instruction fetch unit from initiating a new instruction fetch request to the instruction cache. Send the cached sequence of instructions for the alternative paths to the decoder segment; The updated trajectory end address is sent as the new instruction fetch address to the instruction fetch unit to resume operation of the instruction fetch unit.

[0019] In some implementations, the unpredictable branch record unit is configured as follows: Based on the address of the target branch instruction and the alternative path jump address of the target branch instruction, query the matching data item in the unpredictable branch record; In response to finding a matching data item, update the count of the matching data items; In response to finding a partially matching data item, the address of the target branch instruction and the alternative path jump address of the target branch instruction are recorded in an allocated data item, and the corresponding count is initialized; wherein, the partially matching data item is a data item in which the address of the branch instruction matches the address of the target branch instruction, but the alternative path jump address does not match the alternative path jump address of the target branch instruction.

[0020] In some implementations, the unpredictable branch record has a predetermined number of data items; The unpredictable branch record unit is configured as follows: In response to the existence of a free data item, a free data item is allocated, and the address of the target branch instruction and the alternative path jump address of the target branch instruction are recorded in the free data item; In response to the absence of a free data item, a low-count data item is cleared and allocated to the target branch instruction, and the address of the target branch instruction and the alternative path jump address of the target branch instruction are recorded in the allocated data item.

[0021] In some implementations, the instructions in the cached instruction sequence are the raw, undecoded instructions.

[0022] In some implementations, the data items for unpredictable branch records also include branch mappings, which record the jump direction information of each branch instruction within the alternative path; The unpredictable branch record unit is also configured as follows: The branch history register of the branch predictor is incrementally updated according to the branch mapping.

[0023] Thirdly, an out-of-order execution processor is provided, comprising: Branch prediction unit; Instruction fetch unit; Decoded segment; Rename the section; Launch queue; Submission segment; Execution unit; and The out-of-order execution pipeline control device as described in the second aspect.

[0024] This application embodiment tracks the target branch instructions of alternative paths by feature tracing and records the feature information of the instruction sequence of the alternative paths. During instruction fetching, when the current path corresponds to a branch path corresponding to a data item in the unpredictable branch record, at least a portion of the instruction sequence sent by the instruction fetch unit to the decoder is cached using a bypass detection method based on the feature information corresponding to that data item. If a branch prediction error occurs subsequently, and the alternative path for branch jump has been cached, the instruction sequence corresponding to the data item is injected into the decoder. Therefore, the recovery delay is significantly shortened after a branch prediction error occurs, and zero additional read requests are made to the instruction cache read port during the entire backup instruction reserve process, without affecting the normal instruction fetching bandwidth of the main path. Attached Figure Description

[0025] The above and other objects, features and advantages of the present invention will become more apparent from the following description of embodiments of the invention with reference to the accompanying drawings, in which: Figure 1 This is a block diagram of the pipeline of the out-of-order processor according to an embodiment of the present invention; Figure 2 This is a schematic diagram of the data items of the unpredictable branch record in an embodiment of the present invention; Figure 3 This is a flowchart of the data item maintenance process performed by the unpredictable branch record unit according to an embodiment of the present invention; Figure 4 This is a structural block diagram of the unpredictable branch recording unit according to an embodiment of the present invention; Figure 5 This is a schematic diagram of the storage table entries of the instruction sequence buffer according to an embodiment of the present invention; Figure 6 This is a flowchart illustrating the instruction sequence caching process in an embodiment of the present invention. Figure 7 This is a flowchart illustrating the instruction sequence injection process performed by the instruction sequence buffer in an embodiment of the present invention. Figure 8 This is a structural block diagram of the instruction sequence buffer according to an embodiment of the present invention; Figure 9 This is a state diagram of the instruction sequence buffer according to an embodiment of the present invention; Figure 10 This is an exemplary schematic diagram of the instruction sequence buffer during the dynamic phase of the buffering operation in an embodiment of the present invention; Figure 11 This is a flowchart of the out-of-order pipeline control method according to an embodiment of the present invention. Detailed Implementation

[0026] The present application is described below based on embodiments, but it is not limited to these embodiments. In the detailed description of the present application below, certain specific details are described in detail. Those skilled in the art can fully understand the present application without these details. To avoid obscuring the substance of the present application, well-known methods, processes, flows, elements, and circuits are not described in detail.

[0027] Furthermore, those skilled in the art should understand that the accompanying drawings provided herein are for illustrative purposes only and are not necessarily drawn to scale.

[0028] Unless the context explicitly requires it, words such as "including" or "contains" throughout the application should be interpreted as including rather than exclusive or exhaustive; that is, meaning "including but not limited to".

[0029] In the description of this application, it should be understood that the terms "first," "second," etc., are used for descriptive purposes only and should not be construed as indicating or implying relative importance. Furthermore, in the description of this application, unless otherwise stated, "a plurality of" means two or more.

[0030] Figure 1 This is a block diagram of the pipeline for an out-of-order processor according to an embodiment of the present invention. Figure 1 As shown, the out-of-order processor in this embodiment adopts a typical deep pipeline structure, which includes, from the front end to the back end, a branch prediction unit (BP), an instruction fetch unit (IFU), an instruction cache (I-Cache), a decode stage, a rename stage, an issue queue (IQ), an execution unit (EXU), a reorder buffer (ROB), and a commit stage. The branch prediction unit 11 is responsible for predicting the direction and target address of the branch instructions retrieved by the instruction fetch unit 12 from the instruction cache 13. The instruction fetch unit 12 continuously retrieves instructions from the instruction cache 13 along the prediction path according to the prediction results given by the branch prediction unit 11. The retrieved instructions flow through the decoding segment 14 and the renaming segment 15 in sequence, and enter the launch queue 16 to wait for launch to the execution unit 17 for execution. The executed instructions enter the reordering cache 18 and submit the architecture state in the submission segment 19 according to the program order.

[0031] For branch instructions, when the instruction fetch unit 12 fetches a branch instruction from the instruction cache 13, the branch prediction unit 11 queries its internal branch history register and branch target buffer based on the address of the branch instruction, and outputs the prediction direction (jump or no jump) and the prediction target address. The instruction fetch unit 12 then continues to fetch instructions from the instruction cache 13 along the prediction path according to the prediction direction. Instructions fetched along the prediction path after this branch instruction are all speculative instructions. This branch instruction and subsequent speculative instructions flow through the decode segment 14 and the rename segment 15, and enter the issue queue 16, waiting to be issued to the execution unit 17. When the branch instruction is issued, it is dispatched to the branch execution unit 171 within the execution unit 17, where it is executed and the prediction verification is completed.

[0032] It should be noted that the prediction and verification of branch instructions are not performed in the commit segment 19, but are completed when the instruction is executed in the execution unit 17. Specifically, the execution unit 17 includes a branch execution unit (BRU) 171, which is specifically responsible for the execution and prediction verification of branch instructions. For a branch instruction, after it is issued to the branch execution unit 171 in the issue queue 16, the branch execution unit 171 calculates the actual jump direction and actual jump target address of the branch instruction within a few clock cycles and compares them with the prediction previously given by the branch prediction unit 11. If the comparison matches, the prediction is correct, and the branch instruction continues to flow normally along the pipeline, and subsequent instructions are not affected. If the comparison does not match, the prediction is incorrect, and the branch execution unit 171 broadcasts a signal to the entire pipeline. This broadcast signal includes a global flush signal, the address of the erroneous branch instruction, and the actual jump target address, flushing the speculative instructions that were fetched and executed along the incorrect path after the branch instruction. However, the branch instruction itself is still retained in the reordering cache 18, continuing to wait for its arrival in the commit segment 19. When the branch instruction reaches the commit segment 19, the commit segment 19 outputs its commit information, which includes the instruction address of the branch instruction, the prediction error flag, and the actual jump target address.

[0033] In one implementation, the commit information includes the instruction address of the branch instruction, an identifier indicating whether the instruction is a branch instruction, a prediction error identifier, and the actual jump target address. The unpredictable branch recording unit 110 filters non-branch instructions based on the "whether it is a branch instruction" identifier and processes only the commit information of branch instructions.

[0034] This embodiment introduces two cooperating hardware modules to achieve rapid recovery after branch prediction errors based on the aforementioned pipeline mechanism. In this embodiment, the out-of-order execution processor also includes a difficult-to-predict branch recording unit 110 and an instruction sequence buffer 120. Both are part of the out-of-order execution pipeline control device of this embodiment and are deployed in different locations. The difficult-to-predict branch recording unit 110 is deployed at the front end of the processor, in the same clock domain as the branch prediction unit 11 and the instruction fetch unit 12, and receives branch instruction commit information from the commit segment 19 through a dedicated signal path. The instruction sequence buffer 120 is connected across the data path bypass configured between the instruction fetch unit 12 and the decoding segment 14, and is not connected in series with the main data path, thus not increasing the delay of the conventional instruction fetch and decoding process.

[0035] The out-of-order execution pipeline control device in this embodiment controls the out-of-order instruction pipeline in three stages: branch documentation, bypass caching, and instruction injection.

[0036] The first stage involves creating branch files.

[0037] In this stage, the unpredictable branch recording unit 110 completes the process under the guidance of the backend commit segment 19. As mentioned earlier, when a branch instruction that has experienced a prediction error arrives at the commit segment 19, the commit segment 19 outputs commit information containing the instruction address of the branch instruction, the prediction error identifier, and the actual jump target address. The unpredictable branch recording unit 110 receives this commit information and updates the unpredictable branch record. The unpredictable branch record is a data structure used by the unpredictable branch recording unit 110 for data recording, and it includes multiple independent data items. If the branch instruction and the actual jump target address have been previously recorded in a data item, its prediction error count is incremented. If the branch instruction and the actual jump target address have not been previously recorded in any data item, a new data item is allocated for them, recording their instruction address and alternative path jump address (i.e., the actual jump target address), and the prediction error count is initialized.

[0038] During the update process, if the prediction error count in a certain data item reaches a first threshold, it indicates that the branch instruction has a high number of prediction errors and should be treated as an error-prone branch instruction. The unpredictable branch recording unit 110 identifies the branch instruction corresponding to the data item as the target branch instruction, tracks subsequent execution instructions, records the characteristic information of the instruction sequence of the alternative paths of the target branch instruction, and writes it into the data item. This characteristic information is used to guide the instruction sequence buffer 120 in caching operations of the alternative path instruction sequences in subsequent stages.

[0039] Specifically, since the update occurs when a branch prediction error occurs and the branch instruction is committed by the commit segment, the unpredictable branch recording unit 110 can obtain the instruction sequence of the alternative path that the branch instruction reselects after pipeline flushing. Therefore, by tracing these instructions, the characteristic information of the instruction sequence of the alternative path can be recorded.

[0040] In one implementation, the characteristic information of the instruction sequence of the candidate path is an offset mapping, which records the address offset sequence between adjacent instructions in the instruction sequence of the candidate path.

[0041] In the second stage, bypass caching operations are performed.

[0042] This stage is mainly completed passively by the instruction sequence buffer 120 during the regular instruction fetching process at the front end, without needing to initiate any additional read requests to the instruction buffer 13.

[0043] In one implementation, during normal processor operation, the instruction sequence cache 120 continuously retrieves the current fetch address of the fetch unit 12 and compares the current fetch address and the previous fetch address with the data items recorded in the unpredictable branch record unit 110. When it is detected that the current fetch address matches the alternative path jump address of a certain data item, and the previous fetch address matches the branch instruction address of that data item, it indicates that the fetch unit 12 has reached the alternative path of the target branch instruction along the normal fetch flow. At this time, the instruction sequence cache 120, based on the feature information corresponding to the data item, synchronously copies at least a portion of the instruction sequence sent from the fetch unit 12 to the decode segment 14 from the main data path between the fetch unit 12 and the decode segment 14 using a bypass detection method, and stores it in the internal cache space. Throughout the caching process, the instruction sequence cache 120 does not initiate any read requests to the instruction cache 13, thus not occupying any fetch bandwidth of the main path.

[0044] The third stage involves instruction injection.

[0045] When the branch execution unit 171 issues a branch prediction error broadcast signal, the third stage operation is triggered collaboratively by two modules. When the branch execution unit 171 detects a branch instruction prediction error, it broadcasts a signal containing the address of the erroneous branch instruction and the actual jump target address to the entire pipeline. Within the same clock cycle of receiving the broadcast signal, the unpredictable branch recording unit 110 performs a double match between the erroneous branch instruction address and the actual jump target address in the broadcast signal and the branch instruction address and alternative path jump address recorded in its internal data items. If a data item is found that matches both the branch instruction address and the alternative path jump address, and the caching operation of the instruction sequence corresponding to the data item in the instruction sequence buffer 120 has been completed, the unpredictable branch recording unit 110 sends an injection activation signal to the instruction sequence buffer 120, and the instruction sequence buffer 120 then injects the instruction sequence of the alternative path cached internally into the decoder segment 14. Therefore, the decode segment 14 does not need to wait for the instruction fetch unit 12 to fetch instructions again from the instruction cache 13, and can directly obtain the instruction sequence of the alternative path from the instruction sequence cache 120, thereby greatly shortening the pipeline recovery delay after a branch prediction error.

[0046] From a functional perspective, the unpredictable branch record unit 110 and the instruction sequence cache 120 undertake the task of decoupling the front-end and back-end. The processor back-end (commit segment 19) determines which branch instructions need attention based on the actual execution results, that is, the instruction sequences of their alternative paths need to be cached. The unpredictable branch record unit 110 is responsible for establishing the record for the target branch instructions.

[0047] The processor front-end (the area between the fetch and decode segments) is responsible for data filling and instruction feeding, a task handled by the instruction sequence cache 120. The two paths are independent but work collaboratively. The unpredictable branch recording unit 110 is only responsible for determining which alternative paths to cache based on the statistical results of high-frequency misprediction and generating corresponding feature information for the front-end. The instruction sequence cache 120 is responsible for bypassing caching when an alternative path that has been hit is found during the regular instruction fetch process, and for quickly injecting instructions when a branch prediction error occurs again. This decoupled front-end and back-end architecture avoids the storage space waste and inefficient power consumption caused by blind speculation by the front-end in existing solutions.

[0048] Figure 2 This is a schematic diagram of data items for unpredictable branch records according to an embodiment of the present invention. For example... Figure 2 As shown, the unpredictable branch record is a data structure maintained internally by the unpredictable branch record unit 110, used to manage information about branch instructions that need to be monitored (i.e., unpredictable branches). The unpredictable branch record contains multiple data items with the same structure, each corresponding to a monitored branch instruction and its alternative paths.

[0049] In one implementation, each data item includes a branch instruction address 211 (Branch_PC), a prediction error count 212 (Miss_Cnt), an alternative path jump address 213 (Alt_Path_PC), a branch map 214 (Branch_Map), a state 215 (State), and a trace end address 216 (Trace_Exit_PC).

[0050] It should be understood that the field settings listed above are merely examples and do not imply that they are necessary fields for implementing the basic functions of the unpredictable branch record unit. Designers can add or delete some fields as needed to achieve the recording of unpredictable branch instructions.

[0051] Branch instruction address 211 stores the instruction address of the branch instruction that triggered this data item record. Its bit width is equal to the processor instruction address width, for example, occupying 48 bits in a 48-bit address space. This field also serves as a label for the data item, used for indexing and matching in unpredictable branch records.

[0052] The prediction error count 212 records the number of times the branch instruction was reported as a prediction error by the submission segment 19 within the sampling period. In one implementation, the prediction error count 212 can be maintained by a saturation counter. The bit width of the prediction error count 212 can be configured to 4 bits to 8 bits according to design requirements, corresponding to a maximum count value of 15 or 255 respectively. When the prediction error count of a data item reaches a first threshold (e.g., 50% to 75% of the maximum value of the saturation counter, such as a 4-bit counter reaching 7, or an 8-bit counter reaching 127), the difficult-to-predict branch recording unit 110 determines the branch instruction corresponding to the data item as the target branch instruction and initiates the alternative path feature tracing process for the target branch instruction.

[0053] In one implementation, the prediction error count 2^12 is periodically reset. The processor maintains a global sampling counter ( Figure 1 The sampling period is counted using a global sampling counter (not shown). This global sampling counter increments with each instruction submitted. When the sampling counter reaches a preset sampling period threshold (e.g., every 106 submissions), a global reset event is triggered, and the prediction error count 212 for all data items is simultaneously reset to zero. This periodic reset mechanism allows unpredictable branch records to dynamically adapt to changes in the program execution phase. For example, a branch may frequently mispredict during the program startup phase, but may become easier to predict after the branch prediction unit 11 has warmed up; conversely, after the program enters a new execution phase, previously easily predictable branches may become unpredictable branches. The reset mechanism prevents historical data from occupying data items for extended periods, ensuring that unpredictable branch records always reflect the current prediction characteristics of the program.

[0054] It should be noted that, in one implementation, the global reset event only resets the prediction error count 212 of each data item to zero. Other fields of the data item (such as branch instruction address 211, alternative path jump address 213, branch mapping 214, state 215, and trajectory end address 216) and the cached instruction data in the instruction sequence cache 120 remain unchanged. Data items with zeroed counts become priority replacement candidates in subsequent replacement strategies, and their cached instruction data can still participate in instruction injection in a ready state before being replaced. In another implementation, the global reset event resets all fields of the data item to their initial state, and the corresponding storage table entries in the instruction sequence cache 120 are also cleared, effectively performing a complete reset of the unpredictable branch records and the instruction sequence cache. The two reset strategies can be selected based on the processor design goals and power consumption requirements.

[0055] The alternative path jump address 213 stores the actual jump target address calculated by the branch execution unit 171 after a prediction error occurs, which is also the address of the first instruction of the alternative path. The bit width of the alternative path jump address 213 is equal to the bit width of the instruction address. This field, together with the branch instruction address 211, constitutes two references for subsequent double matching. When the same branch instruction moves to different alternative paths in different execution contexts (for example, a branch instruction moves to two different target addresses in different iterations of a loop), the unpredictable branch recording unit 110 allocates different data items for the different alternative path jump addresses of the branch instruction, thereby supporting tracing and caching in multi-target address scenarios.

[0056] Branch mapping 214 is a composite field used to record the jump direction information of each branch instruction contained in the candidate path, for updating the branch history register of the branch prediction unit 11 during instruction injection. This field contains two subfields: a length subfield (Len) and a direction vector subfield (Direction_Vector). The length subfield records the number of branch instructions contained in the candidate path, and its width is log2(N) bits, where N is the maximum instruction length of a single trajectory, for example, 4 bits for 16 instructions. The direction vector subfield has a width of N bits and records the jump direction of each branch instruction in the candidate path in sequence, where 1 indicates a jump (Taken) and 0 indicates no jump (Not-Taken). Its number of bits is determined by the length subfield; if the value of the length subfield is less than N, the bits in the direction vector subfield that exceed the length value are kept as 0.

[0057] State 215 is used to indicate the working state of the data item and the storage state of the instruction sequence in the corresponding instruction sequence buffer 120. In one implementation, the state encoding includes three states: empty state (e.g., encoding 00), indicating that the instruction sequence storage space corresponding to the data item is free and waiting to be filled; filled state (e.g., encoding 01), indicating that the instruction sequence buffer 120 is passively filling the alternative path corresponding to the data item with instruction sequences; and ready state (e.g., encoding 10), indicating that the corresponding instruction sequence has been fully filled or is ready for injection after dynamic truncation.

[0058] State 215 is consistent with the state machine of instruction sequence buffer 120, which will be described in detail later, so that unpredictable branch record unit 110 and instruction sequence buffer 120 can cooperate according to the state.

[0059] The trajectory end address 216 stores the end address of the recorded candidate path instruction sequence, that is, the address of the instruction following the last instruction in the recorded instruction sequence. The bit width of this field is equal to the bit width of the instruction address. The trajectory end address is calculated by the unpredictable branch recording unit 110 based on the execution trajectory of each instruction on the candidate path during the candidate path feature tracing stage, and may be updated in the subsequent passive filling stage if dynamic truncation occurs. This address is used as the new instruction fetch start address to be sent to the instruction fetch unit 12 after instruction injection is completed, so as to restore the normal instruction fetch operation of the front end.

[0060] Figure 3 This is a flowchart illustrating the data item maintenance process of the unpredictable branch record unit according to an embodiment of the present invention. Figure 3 As shown, in step S310, when a branch instruction is committed in the commit segment 19 and its commit information indicates that the branch instruction has a prediction error, the unpredictable branch record unit 110 uses the address of the branch instruction and the actual jump target address as joint query conditions to perform parallel retrieval in all data items of the unpredictable branch record and attempts to retrieve matching data items.

[0061] The search results fall into three categories.

[0062] In the first case, a complete hit occurs, meaning that the unpredictable branch record unit 110 finds a data item whose branch instruction address 211 matches the branch instruction address in the commit message, and the alternative path jump address 213 matches the actual jump target address in the commit message.

[0063] The second scenario is a partial hit, meaning that the unpredictable branch record unit 110 finds a data item whose branch instruction address 211 matches the commit message, but the alternative path jump address 213 does not match the actual jump target address in the commit message. This indicates that the same branch instruction leads to different alternative paths in different execution contexts.

[0064] The third scenario is a miss: Unpredictable branch record unit 110 did not find any data item matching the branch instruction address 211.

[0065] If the prediction is completely accurate, proceed to step S320, where the prediction error count 212 of the data item is incremented in a saturated manner.

[0066] After incrementing, if the prediction error count reaches a first threshold, then in step S330, the branch instruction is determined as the target branch instruction, triggering alternative path feature tracing. The first threshold is a pre-set threshold used to activate alternative path tracing.

[0067] If the prediction error count after incrementing does not reach the first threshold, return to step S310 and wait for the next branch instruction to be submitted.

[0068] In step S340, the unpredictable branch recording unit 110 performs alternative path feature tracking, that is, based on the execution trajectory information provided by the submission segment 19, it tracks the control flow of the subsequent N instructions (N is the preset maximum number of instructions in the trajectory, such as 16) on the alternative path of the branch instruction, calculates the trajectory end address, and writes it to the trajectory end address 216. In one implementation, the calculation method of the trajectory end address depends on the composition of the N instructions being tracked: if all N instructions are executed sequentially and do not contain branch jumps, then the trajectory end address is equal to the alternative path jump address plus the sum of the offsets of the first N instructions; if the Nth instruction being tracked is a branch jump instruction, then the trajectory end address is equal to the jump target address of the branch jump instruction. The jump direction of each branch instruction in the path is identified and written into the branch mapping 214, and the state 215 is set to an empty state. The instruction sequence buffer 120 waits for the alternative path to be passively filled. Meanwhile, the unpredictable branch record unit 110 also calculates the address offset between adjacent instructions on the candidate path one by one, generates offset mapping as the feature information of the instruction sequence of the candidate path, and writes it into the corresponding storage table entry of the instruction sequence cache 120 to guide subsequent bypass cache operations.

[0069] If a partial hit occurs, proceed to step S350. In step S350, the unpredictable branch recording unit 110 attempts to allocate a data item for this combination of the new branch instruction address and the alternative path jump address: if an empty data item exists (a data item in the Empty state), the empty data item is allocated, and the branch instruction address and the new alternative path jump address are written into the corresponding fields respectively, and the prediction error count is initialized to 1. If no empty data item exists, a data item with a lower count is selected and cleared and replaced according to the replacement strategy.

[0070] Specifically, when all data items in the unpredictable branch record are occupied and new data items need to be allocated, a replacement strategy is executed. The replacement strategy prioritizes candidates in the empty or ready state (candidates in the filled state are not included in the replacement to avoid interrupting the ongoing passive filling process). Among the candidates, the data item with the lowest prediction error count 212 is selected as the sacrifice; the lower the value, the less frequently the corresponding branch instruction has been predicted incorrectly recently. If multiple candidates have the same prediction error count, a second selection is performed using the least recently used strategy. The replacement operation is synchronously applied to the corresponding entries in the unpredictable branch record unit 110 and the instruction sequence buffer 120 to ensure consistency between the two.

[0071] In one implementation, the data item with the lowest count value can be cleared and replaced. In an alternative implementation, any data item with a count value below a certain threshold can be selected for clearing and replacement.

[0072] In another implementation, if no free data item exists and the prediction error count of all replaceable candidates is lower than the current prediction error count of the branch instruction to be assigned (or the branch instruction to be assigned has not yet reached the first threshold), then the assignment is abandoned, and the assignment is attempted again after the subsequent prediction error count of the branch instruction has accumulated further. This avoids replacing more valuable data items due to an accidental partial hit.

[0073] If the prediction fails, proceed to step S360. In step S360, the unpredictable branch record unit 110 also attempts to allocate a new data item: if there is a free data item, it is allocated, the branch instruction address and alternative path jump address are written, and the prediction error count is initialized to 1; if there is no free data item, it is not allocated for the time being, and the prediction error count is waited for to accumulate.

[0074] Figure 4 This is a structural block diagram of the unpredictable branch record unit according to an embodiment of the present invention. Figure 4 As shown, the unpredictable branch recording unit 110 includes three hardware sub-components: branch monitoring and evaluation logic 410, directory table array 420, and parallel matching logic 430.

[0075] Branch monitoring and evaluation logic 410 in Figure 3 The data item maintenance process shown undertakes decision-making functions such as retrieval initiation, count update, threshold determination, and feature tracking. The branch monitoring and evaluation logic 410 has a built-in set of saturation counters 411, each corresponding one-to-one with a data item in the directory table array 420, used for hardware-level maintenance. Figure 2 The predicted error count is 212. The branch monitoring and evaluation logic 410 receives branch instruction commit information from commit segment 19 (corresponding to...). Figure 3 Step S310) involves searching the directory table array 420 using the branch instruction address and the actual jump target address, and executing the operation based on the results of a full hit, partial hit, or miss. Figure 3 The corresponding processing steps S320 to S360 are as follows: When a branch instruction is determined to be the target branch instruction, the branch monitoring and evaluation logic 410 triggers alternative path feature tracking, and the generated offset mapping is written to the instruction sequence buffer 120 through the configuration path.

[0076] Catalog array 420 is Figure 2 The physical storage of each data item is shown. In one implementation, the directory table array 420 can employ a fully associative or set-associative storage structure based on D flip-flops, typically configured with 16 to 64 data items. The directory table array 420 outputs state control signals and offset mapping configuration data to the instruction sequence buffer 120 through a dedicated configuration path, maintaining state synchronization between the two.

[0077] When the parallel matching logic 430 receives the mispredicted broadcast signal from the branch execution unit 171, it performs matching on all data items in the directory table array 420.

[0078] Specifically, within the same clock cycle of receiving the mispredicted broadcast signal from the branch execution unit 171, the parallel matching logic 430 performs parallel matching on all data items in the directory table array 420, completes all three-level matching within one cycle, and outputs the hit / miss signal and the corresponding trajectory end address and branch mapping.

[0079] In one implementation, the parallel matching logic can perform three levels of parallel matching. The first level compares the address of the erroneous branch instruction with the branch instruction address 211. The second level compares the actual jump target address with the alternative path jump address 213. The third level checks whether the status 215 is in a ready state. If all three levels pass, a hit signal is output to the instruction sequence buffer 120, and the trajectory end address is output to the instruction fetch unit 12 and the branch prediction unit 11. The output branch is mapped to the branch prediction unit 11.

[0080] Figure 5This is a schematic diagram of the storage table entries of the instruction sequence buffer according to an embodiment of the present invention. The storage table entries inside the instruction sequence buffer 120 correspond one-to-one with the data items in the unpredictable branch record unit 110. For example... Figure 5 As shown, in one implementation, each storage table entry includes three fields: the original instruction array 510, the offset mapping 520, and the effective length 530. It should be understood that the above field settings are merely examples, and designers can add or delete some fields as needed.

[0081] The raw instruction array 510 is used to store instruction sequences from alternative paths copied from the main data path between the fetch unit 12 and the decode segment 14. The raw instruction array 510 has a capacity of N instructions, where N is a preset maximum number of instructions per path, typically 16. Each entry in the raw instruction array 510 stores one instruction, with a bit width equal to the processor's instruction bit width.

[0082] Instruction sequence cache 120 caches raw, undecoded instructions, not decoded micro-operations. Cached raw instructions instead of micro-operations avoids the significant area overhead required for caching micro-operations (micro-operations are typically much wider than raw instructions) and ensures that injected instructions can pass through the decoding process of decoder segment 14, maintaining compatibility with the processor's existing front-end architecture. During instruction injection, these raw instructions are sent to decoder segment 14 for decoding, just like instructions fetched normally from instruction cache 13. For decoder segment 14 and subsequent pipeline stages, there is no distinction between instructions originating from fetch unit 12 and instruction sequence cache 120; therefore, they are executed out of order, just like other instructions fetched from fetch unit 12.

[0083] Offset map 520 records the expected address offset sequence between adjacent instructions on the candidate path, serving as a reference for the bypass cache stage to verify whether instruction fetch unit 12 proceeds along the expected candidate path. Offset map 520 contains N entries (e.g., numbered 0 to N-1), the contents of which are determined by... Figure 4 The branch monitoring and evaluation logic 410 shown is in the alternative path feature tracking stage (corresponding to...) Figure 3 Step S340) Calculate and write via the configuration path.

[0084] The calculation method for each entry in offset mapping 520 is as follows: Offset_Map[i] = PC_{i+1} - PC_i, where i=0, 1, ..., N-2, PC_0 is equal to the alternate path jump address, and PC_1 to PC_{N-1} are the addresses of the respective instructions immediately following on the alternate path. For sequentially executed consecutive instructions, the offset map 520 stores fixed offsets between adjacent instructions: which are a fixed value of 4 bytes or 2 bytes in a fixed-length instruction set architecture (such as the ARM architecture), and are the length of each instruction itself in a variable-length instruction set architecture (such as the x86 architecture). For the case where the alternate path contains a branch jump instruction, if a certain instruction is a taken branch, the corresponding position in the offset map 520 stores a large-span offset from the address of the branch instruction to the address of its jump target instruction, and this offset may be a positive value or a negative value. During the process of calculating the offset map 520, if the address offset between a certain pair of adjacent instructions exceeds the bit width of a single entry in the offset map 520, the trace recording is terminated in advance, the number of valid instructions is reduced accordingly, and the entries in the offset map 520 beyond the portion do not store valid data.

[0085] Therefore, for an instruction sequence, whether in a fixed-length instruction architecture or a variable-length instruction architecture, the offsets of a plurality of adjacent instructions can uniquely identify a segment of the instruction sequence in a piece of program, so as to serve as the feature information of the instruction sequence.

[0086] It should be understood that although the present embodiment adopts the offset map as the feature information of the instruction sequence, designers may also adopt other parameters of the instructions as the feature information to locate and identify a segment of the instruction sequence according to needs and architecture characteristics.

[0087] In the bypass cache stage, the instruction sequence buffer 120 compares the actual address offset between the current instruction fetch address and the previous cycle's instruction fetch address with the pre-stored offset at the corresponding position in the offset map 520 item by item in each clock cycle, so as to determine whether the actual instruction fetch flow of the instruction fetch unit 12 deviates from the expected control flow of the alternate path, and the specific details are described in Figure 6 the relevant steps in detail.

[0088] The valid length 530 records the number of consecutively valid instructions in the original instruction array 510. The bit width of the valid length 530 is log2(N) bits. For example, it occupies 4 bits when N=16. The valid length 530 increases as instructions are successfully filled one by one during the bypass cache stage: the initial value is 0, and it increases by 1 each time one instruction is successfully cached (the offset verification is passed). If the entire filling process is completed smoothly, the valid length 530 is finally recorded as N, indicating that all N instructions in the original instruction array 510 are valid. If dynamic truncation is triggered during the filling process, the valid length 530 is recorded as the number k of instructions that have been successfully matched before the truncation occurs (k<N), indicating that only the first k instructions of the original instruction array 510 are effectively cached, and the data in subsequent entries is invalid.

[0089] Figure 6This is a flowchart illustrating the instruction sequence caching process in an embodiment of the present invention. Figure 6 The process shown is used to passively cache the instruction sequence of the alternative path by the instruction sequence buffer when the normal instruction fetch flow of the instruction fetch unit 12 naturally passes through the alternative path of a certain target branch instruction.

[0090] In step S610, the instruction sequence buffer 120 obtains the current fetch address output by the fetch unit 12. In each clock cycle, the fetch unit 12 outputs a new fetch address, and the instruction sequence buffer 120 obtains this address synchronously with the decoder segment via bypass detection.

[0091] In step S620, the instruction sequence buffer 120 compares the current instruction fetch address and the previous instruction fetch address with the branch instruction address and alternative path jump address recorded in each data item of the unpredictable branch record unit 110.

[0092] In one implementation, the current instruction fetch address is compared in parallel with the candidate path jump addresses 213 of all data items in the unpredictable branch record unit 110 that are in an empty state. For candidate data items whose candidate path jump addresses match, the previous instruction fetch address of the current instruction fetch address is further compared with the branch instruction address 211 of that data item. If there is no data item whose two data items match, it means that the instruction fetch unit 12 is not currently proceeding along any recorded candidate path, and returns to step S610 to continue detecting the next instruction fetch address.

[0093] If the current fetch address matches the jump address of a candidate path for a data item, and the previous fetch address matches the branch instruction address of that data item, it means that the fetch unit 12 just fetched the last instruction of the target branch instruction in the previous cycle, and in this cycle, it has just reached the first instruction of the candidate path for the target branch instruction along the normal fetch flow. At this time, jump to step S630 to trigger the cache operation. In step S630, the instruction sequence buffer 120 sends a hit signal to the unpredictable branch record unit 110, and the unpredictable branch record unit 110 updates the state 215 of the data item from empty to filled, and the instruction sequence buffer 120 enters the passive filling process.

[0094] In step S640, the instruction sequence buffer 120 copies the original instruction corresponding to the current fetch address from the main data path (e.g., the output of the fetch queue) between the fetch unit 12 and the decode segment 14, and writes it into the current fill position i of the original instruction array 510. Here, i is a fill counter, which is initially 0 and increments after each instruction is successfully filled.

[0095] In step S650, it is determined whether the current fill counter i is 0. If i is equal to 0, it indicates that the currently filled instruction is the first instruction of the alternative path. Since the address of the first instruction has been confirmed by matching the current fetch address with the alternative path jump address in step S620, no offset check is required, and the process directly jumps to step S670.

[0096] If i is greater than 0, it indicates that the currently filled instruction is not the first instruction, and an offset check needs to be performed in step S660. The instruction sequence buffer 120 calculates the actual address offset Actual_Offset = Fetch_PC[i] - Fetch_PC[i-1] between the current fetch address Fetch_PC[i] and the fetch address Fetch_PC[i-1] of the previous cycle, and compares this actual offset with the pre-stored offset Offset_Map[i-1] of the (i-1)-th entry in the offset map 520.

[0097] In response to Actual_Offset being equal to Offset_Map[i-1], it indicates that the current instruction fetch flow still proceeds along the expected alternative path recorded in the offset map 520, and the current instruction belongs to the correct alternative path instruction sequence, and the process proceeds to step S670.

[0098] If Actual_Offset is not equal to Offset_Map[i-1], it indicates that the current instruction fetch flow deviates from the expected alternative path. For example, a certain secondary branch instruction in the alternative path takes a jump direction different from that recorded in the branch map 214 during execution, resulting in the subsequent actual fetch address not matching the expected address pre-stored in the offset map 520. At this time, a dynamic truncation operation is triggered, that is, in step S680, the effective length 530 is set to the value of the current fill counter i (i.e., the first i instructions that have been successfully filled), the current fetch address is used as the updated trace end address, which is written back through the configuration path to the trace end address 216 of the corresponding data entry in the hard-to-predict branch recording unit 110, subsequent filling is stopped, and the process jumps to step S690. After dynamic truncation, although the caching operation is terminated early, the first i cached instructions are still valid and can be used for instruction injection when a subsequent branch prediction error occurs.

[0099] In step S670, it is determined whether the fill counter i has reached N-1, where N is the preset maximum number of instructions for a trace. If i < N-1, it indicates that the capacity of the original instruction array 510 has not been filled, the fill counter is incremented (i++), the process returns to step S640, and the next instruction continues to be cached in the next clock cycle. If i is equal to N-1, it indicates that N instructions have been successfully and continuously cached and all offset checks have passed, and the process proceeds to step S680.

[0100] In step S690, the caching operation ends (whether it completes normally or is dynamically truncated). If it completes normally, the effective length 530 is recorded as N. The instruction sequence cache 120 sends a fill completion signal to the unpredictable branch recording unit 110, and the unpredictable branch recording unit 110 updates the state 215 of the corresponding data item from the fill state to the ready state. At this point, the instruction sequence of the alternative path corresponding to this data item has been fully cached and is ready to be injected and used in case of subsequent branch prediction errors. It should be noted that in Figure 6 During the caching process shown, the instruction sequence cache 120 does not need to initiate any independent read requests to the instruction cache 13. All instructions are obtained by bypassing the main data path, so the instruction fetch bandwidth of the main path is not occupied.

[0101] Figure 7 This is a flowchart of the instruction sequence injection process performed by the instruction sequence buffer in an embodiment of the present invention. Figure 7 The process shown is triggered when the corresponding branch prediction error event occurs after an alternative path is filled to a ready state, in order to replace the regular recovery process of re-fetching instructions from instruction cache 13.

[0102] In step S710, when the branch execution unit 171 detects a branch instruction prediction error, it broadcasts a signal to the entire pipeline. This broadcast signal includes a global flush signal, the address of the erroneous branch instruction (Broadcast_Branch_PC), and the actual jump target address (Broadcast_Target_PC). The parallel matching logic 430 of the unpredictable branch recording unit 110 executes the corresponding matching logic on all data items in the directory table array 420 within the same clock cycle after receiving the broadcast signal. Figure 4 The aforementioned parallel matching.

[0103] If all parallel matching passes, meaning there exists a data item whose branch instruction address 211 equals Broadcast_Branch_PC, alternative path jump address 213 equals Broadcast_Target_PC, and state 215 is ready, then the parallel matching logic 430 sends an injection activation signal to the instruction sequence buffer 120, and the process proceeds to step S720. If any matching result in the parallel matching is a mismatch, then a miss occurs, and the process proceeds to step S760. The processor performs pipeline flushing and instruction re-fetching according to the normal process, and this fast recovery process is not triggered.

[0104] In step S720, the instruction sequence buffer 120 receives the injection activation signal, switches its state machine from the filled state to the instruction injection state, and begins to execute the instruction injection operation. Within the same clock cycle, the unpredictable branch recording unit 110 sends a halt signal (Halt) to the instruction fetch unit 12, preventing the instruction fetch unit 12 from initiating new instruction fetch requests to the instruction buffer 13 in the current and subsequent cycles.

[0105] In one implementation, the unpredictable branch recording unit 110 sends the pause signal to the instruction fetch unit 12 via the instruction sequence buffer 120.

[0106] In another implementation, the unpredictable branch recording unit 110 can also be directly signal-connected to the instruction fetching unit 12 to directly send the pause signal.

[0107] In this embodiment, the purpose of pausing the instruction fetch unit 12 is twofold: first, to ensure that during instruction injection, the instruction fetch unit 12 will not compete with the instruction sequence buffer 120 for the write port of the decode segment 14; and second, to avoid redundant access to the instruction cache 13, thereby saving dynamic power consumption.

[0108] In step S730, the instruction sequence buffer 120 reads the original instructions one by one from the original instruction array 510 corresponding to the hit data item, in the order of entry 0 to entry (effective length - 1), and continuously sends them to the decode segment 14 (written to the decode queue) at the maximum physical bandwidth of the pipeline (e.g., 16 bytes per cycle). The instruction sending process and the normal instruction fetch process physically reuse the same write port for the write operation of the decode segment 14. Arbitration logic is set to ensure that there is no conflict between the two: during the injection period, since the instruction fetch unit 12 has been suspended, the write port is exclusively used by the instruction sequence buffer 120.

[0109] Within the same clock cycle of step S730, the unpredictable branch recording unit 110 also sends the trajectory end address 216 in the hit data item to the instruction fetch unit 12 and the branch prediction unit 11 as the new instruction fetch start address. This trajectory end address replaces the Broadcast_Target_PC given by the branch execution unit 171 because: after the instruction sequence buffer 120 has injected all valid length bar instructions into the decoder segment 14, the decoder segment 14 already has the previous valid length bar instructions on the alternative path, and the instruction fetch unit 12 needs to continue normal instruction fetching from the trajectory end address to avoid repeatedly fetching the already injected instructions.

[0110] In one implementation, steps S720 and S730 are performed in parallel within one clock cycle. That is, upon receiving the injection activation signal, the instruction sequence buffer 120 performs the following parallel operations within the same clock cycle: the instruction sequence buffer 120 switches its state machine from the filled state to the instruction injection state; the unpredictable branch recording unit 110 sends a pause signal to the instruction fetch unit 12; and the unpredictable branch recording unit 110 sends the trajectory end address of the hit data item to the instruction fetch unit 12 and the branch prediction unit 11.

[0111] In one implementation, to ensure subsequent performance, in step S740, the unpredictable branch record unit 110 performs an incremental update of the branch history register (BHR) of the branch prediction unit 11.

[0112] The unpredictable branch recording unit 110 reads the direction vector subfield (Direction_Vector) from the branch mapping 214 of the hit data item. This direction vector records the jump direction of each branch instruction in the order of appearance of the branch instructions in the candidate path (1 indicates a jump, 0 indicates no jump). The unpredictable branch recording unit 110 pushes each direction bit in the direction vector into the BHR shift register of the branch prediction unit 11 in sequence, from the direction bit of the first branch to the direction bit of the last branch. The purpose of this operation is that after instruction injection, the instruction fetch flow of the front end has switched from the erroneous path to the candidate path, but the branch history in the BHR still reflects the historical state on the erroneous path. By pushing the actual jump direction of each branch instruction in the candidate path into the BHR, the internal state of the branch prediction unit 11 is kept consistent with the branch history in the injected instruction sequence, thereby ensuring that the prediction accuracy of subsequent branch instructions is not affected by the injection operation.

[0113] In step S750, after the instruction sequence buffer 120 has completed sending all instructions of valid length, the state machine releases the injection state and sends an injection completion signal to the unpredictable branch recording unit 110. The unpredictable branch recording unit 110 cancels the pause signal sent to the instruction fetching unit 12, and the instruction fetching unit 12 resumes normal instruction fetching from the trajectory end address. Thus, a complete branch prediction error fast recovery process ends.

[0114] pass Figure 7 The process shown reduces the pipeline recovery delay after a branch prediction error from the usual dozens of cycles (requiring pipeline flushing, waiting for instruction fetch unit 12 to re-fetch instructions from instruction cache 13, and then filling decode segment 14 and subsequent pipeline stages) to just a few cycles required for instruction injection, resulting in a significant reduction in recovery delay.

[0115] Figure 8 This is a state diagram of the instruction sequence buffer according to an embodiment of the present invention. For example... Figure 8 As shown, each storage entry in the instruction sequence buffer 120 goes through three states during its lifetime: Empty (810), Filling (820), and Ready (830). The state of each storage entry inside the instruction sequence buffer 120 is always synchronized with the state 215 of the corresponding data entry in the unpredictable branch record unit 110, and the two notify each other during state transitions through state control signals.

[0116] Empty state 810 is the initial state of a storage table entry, indicating that the storage space corresponding to the entry is free and no instruction sequence is cached. The state 215 of the data item in the unpredictable branch record unit 110 corresponding to the entry in empty state 810 is an empty state code (e.g., 00). When the processor is running normally, the instruction sequence cache 120 continues to execute. Figure 6 Address monitoring in steps S610 to S620. When the address comparator array 920 detects that the current fetch address matches the alternative path jump address of the data item corresponding to an empty state 810 entry, and the previous fetch address matches the branch instruction address of that data item, a state transition is triggered: the state of the entry changes from empty state 810 to filled state 820. At the same time, the instruction sequence buffer 120 notifies the unpredictable branch record unit 110 to synchronously update the state 215 of the corresponding data item to the filled state code (e.g., 01).

[0117] Status 820 indicates that the entry is being processed. Figure 6 The bypass caching operations in steps S640 to S660 copy instructions from the main data path between the instruction fetch unit 12 and the decode segment 14 to the original instruction array 510 cycle by cycle. Entries in the fill state 820 do not participate in the candidate selection for the replacement strategy of the unpredictable branch record unit 110 to avoid interrupting the ongoing passive filling process. When the filling operation ends, there are two possible outcomes. The first outcome is that the filling is completed normally, that is, N instructions are successfully cached consecutively and all offset checks pass, with the effective length 530 recorded as N. The second outcome is that the filling is dynamically truncated, that is, offset checks fail during the filling process, with the effective length 530 recorded as the number of instructions k before the truncation point. Regardless of the outcome, the state of the entry changes from the fill state 820 to the ready state 830. Simultaneously, the instruction sequence buffer 120 notifies the unpredictable branch record unit 110 to synchronously update the state 215 of the corresponding data item to the ready state code (e.g., 10).

[0118] Ready state 830 indicates that the sequence of alternative path instructions (valid length bar) corresponding to the entry has been fully cached and is ready for injection in case of a branch prediction error in the corresponding branch instruction. When the branch execution unit 171 issues a misprediction broadcast signal, and the parallel matching logic 430 of the difficult-to-predict branch record unit 110 finds that all three levels of matching of the data item corresponding to the entry have passed, the instruction sequence buffer 120 injects the instruction sequence in the entry into the decoded segment 14. Figure 7 Step S730). After injection, the entry remains in the ready state 830, and the data in its cached original instruction array 510 remains unchanged. Thus, if the same branch instruction subsequently experiences another prediction error, and the alternative path is the same as before, the instruction sequence cache 120 can directly use the cached instruction sequence for injection without waiting for refilling. When the unpredictable branch record unit 110 re-triggers alternative path feature tracing for this data item in a subsequent maintenance process (corresponding to...), Figure 3 In step S340, the state changes from ready state 830 back to empty state 810, the cached old instruction sequence is overwritten by the new alternative path instruction sequence, and a new cycle of filling begins.

[0119] Figure 9 This is a structural block diagram of the instruction sequence buffer according to an embodiment of the present invention. Figure 9 As shown, the instruction sequence buffer 120 includes three hardware sub-components: a finite state machine controller 910, an address comparator array 920, and an SRAM payload array 930.

[0120] Finite state machine controller 910 drives instruction sequence buffer 120 in Figure 8 The system transitions between the three states shown and controls the switching between passive fill mode and instruction injection state. In standby mode, the finite state machine controller 910 is in passive fill mode, monitoring the output of the address comparator array 920. Upon detecting a match, it triggers a state transition from empty to fill mode, controlling the SRAM payload array 930 to perform bypass copying operations. After filling is complete or dynamic truncation, it triggers a state transition from fill mode to ready mode. Upon receiving the injection activation signal from the unpredictable branch record unit 110, the finite state machine controller 910 switches to instruction injection state, controlling the SRAM payload array 930 to perform instruction sending operations. After injection is complete, the injection mode is released and standby mode is restored.

[0121] Address comparator array 920 contains a set of parallel hardware comparators that execute in each clock cycle. Figure 6 The address detection and matching function in steps S610 to S620 simultaneously notifies the finite state machine controller 910 and the unpredictable branch recording unit 110 when the matching is successful.

[0122] SRAM payload array 930 is Figure 5 The physical storage of each memory table entry is shown, where the capacity M is the same as the number of data items in the unpredictable branch record. The SRAM payload array 930 copies the original instruction from the main data path in passive fill mode through the bypass write port, and sends the instruction to the decode segment 14 in instruction injection state.

[0123] Figure 10 This is an exemplary schematic diagram illustrating the dynamic truncation of the instruction sequence buffer during caching operations according to an embodiment of the present invention. To facilitate understanding of the complete process of branch documentation, bypass caching, dynamic truncation, and instruction injection described in the above figures, the following is combined with... Figure 10 This example illustrates the entire process of a branch instruction from its initial recording by the unpredictable branch recording unit 110 to its eventual fast injection. The example assumes a maximum number of instructions N=8, and the out-of-order execution pipeline uses a fixed-length instruction set architecture (4 bytes per instruction).

[0124] Suppose the processor executes a conditional branch instruction located at address 0x1000. Upon initial execution of this branch instruction, branch prediction unit 11 predicts a not-taken direction. However, branch execution unit 171, after execution, confirms the actual direction is a take, with the actual jump target address being 0x2000. Branch execution unit 171 sends a broadcast signal (Broadcast_Branch_PC=0x1000, Broadcast_Target_PC=0x2000) to flush the speculated instruction on the erroneous path, and the processor fetches the instruction again from 0x2000. When the branch instruction finally reaches commit segment 19, commit segment 19 outputs a commit message (branch instruction address = 0x1000, prediction error, actual jump target address = 0x2000).

[0125] The unpredictable branch recording unit 110 receives the commit message. Upon searching, the branch instruction address 211, which has no data item in the directory table array 420, is equal to 0x1000, resulting in a miss. The unpredictable branch recording unit 110 initializes the prediction error count to 1, the branch instruction address 211 = 0x1000, the alternative path jump address 213 = 0x2000, and the state 215 = empty state. Subsequently, this branch instruction experiences multiple prediction errors during program execution. Each time the commit segment 19 is reached, the unpredictable branch recording unit 110 finds the data item to be fully hit, and the branch monitoring and evaluation logic 410 increments its saturation counter 411.

[0126] Assume the first threshold is set to 7. When the prediction error count for this data item reaches 7, the branch monitoring and evaluation logic 410 identifies the branch instruction as the target branch instruction and triggers alternative path feature tracing. The unpredictable branch recording unit 110 tracks the execution trajectory of subsequent instructions on the alternative path starting from 0x2000, assuming the actual control flow of the alternative path is: 0x2000 (ADD instruction) 0x2004 (SUB instruction) 0x2008 (conditional branch instruction, actually jumps to 0x3000) 0x3000 (LOAD instruction) 0x3004 (STORE instruction) 0x3008 0x300C 0x3010 (8 entries in total).

[0127] The branch monitoring and evaluation logic 410 calculates the end address of the trajectory as 0x3014, generates an offset mapping (Offset_Map[0]=4, Offset_Map[1]=4, Offset_Map[2]=0x3000-0x2008=8, Offset_Map[3]=4, ...Offset_Map[6]=4), records the branch mapping (the path contains 1 branch instruction, the direction is Taken), writes the corresponding field, and sets the status 215 to an empty status.

[0128] At some point later, the processor encounters a branch instruction at address 0x1000 again. This time, branch prediction unit 11 correctly predicts a jump to 0x2000. Instruction fetch unit 12 fetches instruction 0x1000 (the branch instruction itself), and subsequent instructions are flown to 0x2000 under the control of prediction unit 11. The address comparator array 920 of instruction sequence buffer 120 detects that the previous fetch address = 0x1000 (matching the branch instruction address 211 of this data item) and the current fetch address = 0x2000 (matching the alternative path jump address 213). A match is found, the state changes from empty to filled, and passive filling begins.

[0129] Instruction sequence buffer 120 bypasses and copies instructions cycle by cycle: In cycle 1, the instruction at 0x2000 is cached to the original instruction array 510[0]; in cycle 2, the instruction at 0x2004 is cached to [1]; in cycle 3, the instruction at 0x2008 is cached to [2]. In these three cycles, the offset check passes. However, in cycle 4, the fetch address output by instruction fetch unit 12 is 0x200C instead of the expected 0x3000. The reason is that in this execution, the conditional branch instruction at 0x2008 actually took the non-jump direction. The actual offset is calculated as 0x200C-0x2008=4, which is inconsistent with the large span offset of Offset_Map[2] in offset mapping 520. Dynamic truncation is triggered: the effective length 530 is recorded as 3, the trajectory end address is updated to 0x200C and written back to the trajectory end address 216, and the state is changed to ready state. At this point, only the first three instructions (0x2000, 0x2004, 0x2008) in the original instruction array 510 are cached.

[0130] Subsequently, the branch instruction (0x1000) again experienced a prediction error, and the actual jump target address remained 0x2000. Branch execution unit 171 issued a broadcast signal (Broadcast_Branch_PC=0x1000, Broadcast_Target_PC=0x2000). The parallel matching logic 430 passed all three levels of matching, and the difficult-to-predict branch recording unit 110 sent an injection activation signal to the instruction sequence buffer 120, while simultaneously sending a pause signal to the instruction fetch unit 12. The instruction sequence buffer 120 sent the three valid instructions (0x2000 ADD, 0x2004 SUB, 0x2008 branch) from the original instruction array 510 to the decoding segment 14 one by one, and used the trajectory end address 0x200C as the new instruction fetch start address. Simultaneously, the direction bit (Taken) in the branch mapping was pushed into the BHR of the branch prediction unit 11. After the injection was completed, the pause signal was removed, and the instruction fetch unit 12 resumed normal instruction fetching from 0x200C.

[0131] In the example above, although the secondary branch in the alternative path moves in a different direction during this execution than it did when the file was created, the dynamic truncation mechanism still ensures that the cached, control-flow-consistent first three instructions are effectively utilized. The recovery operation from branch prediction errors no longer requires re-fetching and decoding instructions at 0x2000, 0x2004, and 0x2008 from instruction cache 13, significantly reducing recovery latency.

[0132] Figure 11 This is a flowchart of the out-of-order pipeline control method according to an embodiment of the present invention. Figure 11 As shown, the out-of-order pipeline control method of this embodiment includes the following steps: In step S1110, the target branch instruction for which feature tracing of the candidate path needs to be performed is determined, and the feature information of the instruction sequence of the candidate path of the target branch instruction is recorded.

[0133] Alternate paths refer to the paths that the target branch instruction should jump to again after a branch prediction error. The determination of the target branch instruction is based on the branch instruction commit information provided by the processor's backend commit segment; only branch instructions that have actually experienced a certain frequency of prediction errors are identified as target branch instructions. The recorded feature information reflects the control flow characteristics of the instruction sequences on the alternative paths, and is used to guide the identification and caching of instruction sequences on the alternative paths in subsequent steps.

[0134] In step S1120, the current instruction fetch address of the instruction fetch unit is obtained.

[0135] This step is performed continuously during normal processor operation to provide instruction fetch address data for subsequent alternative path matching detection.

[0136] In step S1130, when it is detected that the current fetch address matches the alternative path jump address of a data item record in the unpredictable branch record, and the previous fetch address of the current fetch address matches the branch instruction address of the data item record, at least a portion of the alternative path instruction sequence sent by the fetch unit to the decode segment is cached in a bypass detection manner according to the feature information corresponding to the matching data item.

[0137] This caching operation utilizes the existing instruction data stream on the main data path and is implemented through bypass copying, eliminating the need to initiate a separate read request to the instruction cache.

[0138] In step S1140, in response to receiving a broadcast signal of a branch prediction error, the address of the erroneous branch instruction and the actual jump target address carried in the broadcast signal are matched with the branch instruction address and alternative path jump address recorded in each data item of the unpredictable branch record.

[0139] In step S1150, if a data item is found where both the branch instruction address and the alternative path jump address match, and the cache operation of the alternative path instruction sequence corresponding to the data item has been completed, the cached instruction sequence corresponding to the data item is injected into the decoder segment, thereby replacing the conventional operation of re-fetching instructions from the instruction cache and realizing the rapid recovery of the pipeline after a branch prediction error.

[0140] This application embodiment uses the branch instruction submission information provided by the backend submission segment to determine the target branch instruction that needs feature tracking of the candidate path, and records the feature information of the instruction sequence of the candidate path; during the normal instruction fetching process, when the current instruction fetch address and the previous instruction fetch address indicate that the current path corresponds to the branch path corresponding to a data item in the unpredictable branch record, at least part of the instruction sequence sent by the instruction fetch unit to the decoding segment is cached through bypass detection based on the feature information corresponding to the data item; after receiving the broadcast signal of branch prediction error, the address of the erroneous branch instruction and the actual jump target address in the broadcast signal are double-matched with the branch instruction address and the candidate path jump address of the data item in the unpredictable branch record; when a data item is found where both addresses match and the corresponding instruction sequence is cached and ready, the instruction sequence corresponding to the data item is injected into the decoding segment.

[0141] Therefore, the embodiments of this application solve the problems in the existing solutions, such as the front-end actively prefetching alternative path instructions causing the instruction fetching bandwidth to be contested, blind speculation leading to low cache hit rate and wasted power, and the non-targeted recovery mechanism causing the latency to still be high. It achieves the effect of significantly shortening the recovery latency after a branch prediction error occurs, and at the same time, it achieves zero additional read requests to the instruction cache read port during the entire backup instruction reserve process, without affecting the normal instruction fetching bandwidth of the main path.

[0142] Furthermore, by determining the target branch instruction based on the comparison between the count of branch instruction prediction errors and a first threshold, this embodiment of the application can concentrate cache resources on high-frequency mispredicted branches actually confirmed by the backend, avoiding blind prefetching based on frontend confidence and improving the hit rate and utilization of cache resources.

[0143] Furthermore, by specifying the feature information as an offset mapping, the embodiments of this application can use the address offset sequence pre-calculated and written by the backend as a reference during the passive caching stage to verify the instruction address actually output by the instruction fetch unit line by line, thereby ensuring that the cached instruction sequence is consistent with the actual control flow of the alternative path.

[0144] Furthermore, by triggering dynamic truncation when the offset mapping verification is inconsistent, the embodiments of this application can terminate the cache operation in a timely manner when the secondary branch in the alternative path is different from the expected one, and update the trajectory end address with the current actual instruction fetch address, thus avoiding storing instructions from the wrong path in the cache.

[0145] Furthermore, by sending a pause signal to the instruction fetch unit when injecting the instruction sequence, and using the updated alternative path end address as the new instruction fetch start address after injection, this embodiment of the application achieves a seamless connection between the instruction injection stage and the regular instruction fetch stage. After injection, the instruction fetch unit can directly continue fetching instructions from the correct address, avoiding the repeated fetching of injected instructions.

[0146] Furthermore, by handling the three cases of complete match, partial match and miss in unpredictable branch records separately, and by using cache management strategies such as allocating free data items and replacing low-count data items, the embodiments of this application can support multi-target address scenarios where the same branch instruction moves to different alternative paths in different execution contexts, and make reasonable use of limited cache resources.

[0147] Furthermore, by limiting the cached instruction sequence to undecoded raw instructions, this embodiment avoids the area overhead and decoding power consumption caused by storing decoded micro-operations in the cache, while ensuring that the injected instructions can go through the normal decoding process of the decoding segment and are compatible with the processor's original front-end architecture.

[0148] Furthermore, by maintaining branch mappings in the unpredictable branch records and incrementally updating the branch history register of the branch predictor according to the branch mappings during instruction injection, the embodiments of this application enable the branch predictor to reflect the branch history in the injected instruction sequence after injection, thereby ensuring that the prediction accuracy of subsequent branch instructions is not affected by the injection operation.

[0149] It should be noted that although the above embodiments mainly describe the composition and operation of the unpredictable branch record unit 110 and the instruction sequence buffer 120 in terms of functional modules and data flow, it should be understood that all the above functional modules are implemented in the form of hardware circuits. For example, the saturation counter 411 in the branch monitoring and evaluation logic 410 is composed of hardware flip-flops, the directory table array 420 is implemented by a D flip-flop array, the parallel matching logic 430 is implemented by a parallel hardware comparator, the finite state machine controller 910 is implemented by a hardware state machine circuit, the address comparator array 920 is implemented by a hardware comparator group, and the SRAM payload array 930 is implemented by a static random access memory. The signal paths and control signals between the various modules are also implemented through hardware interconnects. Based on the functions, structures, and data flows described in the above embodiments, standard digital circuit design methods (such as register transfer level design, logic synthesis, and physical placement and routing processes) can be used to implement the out-of-order execution pipeline control device and out-of-order execution processor described in the embodiments of this application.

[0150] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.

Claims

1. A method for out-of-order execution pipeline control, characterized in that, The method includes: Identify the target branch instruction for which feature tracking of alternative paths is required, and record the feature information of the instruction sequence of the alternative paths of the target branch instruction. The alternative paths are the paths through which the target branch instruction jumps again after a branch prediction error. Get the current instruction fetch address of the instruction fetch unit; In response to the current fetch address matching the alternative path jump address of at least one data item in the unpredictable branch record, and the previous fetch address of the current fetch address matching the address of the branch instruction of the data item, at least a portion of the instruction sequence sent by the fetch unit to the decoder is cached by bypass detection based on the feature information of the instruction sequence of the alternative path corresponding to the matched data item. In response to receiving a broadcast signal indicating a branch prediction error, the address of the erroneous branch instruction and the actual jump target address carried in the broadcast signal are matched with the address of the branch instruction and the alternative path jump address in the data item of the unpredictable branch record, respectively. In response to the discovery of a data item that matches both the address of the branch instruction and the jump address of the alternative path, and the completion of the caching operation of the instruction sequence corresponding to the data item, the instruction sequence corresponding to the data item is injected into the decoder segment.

2. The method according to claim 1, characterized in that, The target branch instructions that require caching operations include: In response to a branch prediction error, the unpredictable branch record is updated based on the branch instruction commit information provided by the commit segment. The unpredictable branch record includes multiple data items, each of which includes at least the address of the corresponding branch instruction, the address of the corresponding alternative path jump, and the count of the branch instruction prediction error. In response to the count in the data item of the unpredictable branch record reaching a first threshold when updating the data item, the branch instruction of the data item is taken as the target branch instruction.

3. The method according to claim 2, characterized in that, The characteristic information of the instruction sequence of the candidate path is the offset mapping, which records the address offset sequence between adjacent instructions in the instruction sequence of the candidate path.

4. The method according to claim 3, characterized in that, By using a bypass detection method, at least a portion of the instruction sequence sent from the instruction fetch unit to the decode segment includes: The address offset between adjacent instructions sent by the instruction fetch unit to the decode segment is compared with the offset at the corresponding position in the offset mapping; In response to a match, cache the current instruction; In response to a mismatch, the cache operation is completed and the trajectory end address is updated to the current fetch address.

5. The method according to claim 4, characterized in that, Injecting the instruction sequence corresponding to the data item into the decode segment includes: Send a pause signal to the instruction fetch unit to prevent it from making a new instruction fetch request to the instruction cache; Send the cached sequence of instructions for the alternative paths to the decoder segment; The updated trajectory end address is sent as the new instruction fetch address to the instruction fetch unit to resume operation of the instruction fetch unit.

6. The method according to claim 2, characterized in that, Updating unpredictable branch records includes: Based on the address of the target branch instruction and the alternative path jump address of the target branch instruction, query the matching data item in the unpredictable branch record; In response to finding a matching data item, update the count of the matching data items; In response to finding a partially matching data item, the address of the target branch instruction and the alternative path jump address of the target branch instruction are recorded in an allocated data item, and the corresponding count is initialized; wherein, the partially matching data item is a data item in which the address of the branch instruction matches the address of the target branch instruction, but the alternative path jump address does not match the alternative path jump address of the target branch instruction.

7. The method according to claim 6, characterized in that, The unpredictable branch record has a predetermined number of data items; The address of the target branch instruction and the alternative path jump address of the target branch instruction are recorded in an allocated data item, including: In response to the existence of a free data item, a free data item is allocated, and the address of the target branch instruction and the alternative path jump address of the target branch instruction are recorded in the free data item; In response to the absence of a free data item, a low-count data item is cleared and allocated to the target branch instruction, and the address of the target branch instruction and the alternative path jump address of the target branch instruction are recorded in the allocated data item.

8. The method according to claim 1, characterized in that, The instructions in the cached instruction sequence are raw instructions that have not been decoded.

9. The method according to claim 1, characterized in that, The data items for unpredictable branch records also include branch mappings, which record the jump direction information of each branch instruction within the alternative paths; The method further includes: The branch history register of the branch predictor is incrementally updated according to the branch mapping.

10. A disordered execution pipeline control device, characterized in that, The device includes a difficult-to-predict branch record unit and an instruction sequence buffer; The unpredictable branch record unit is configured as follows: Identify the target branch instruction for which feature tracking of alternative paths is required, and record the feature information of the instruction sequence of the alternative paths of the target branch instruction. The alternative paths are the paths through which the target branch instruction jumps again after a branch prediction error. as well as In response to receiving a broadcast signal indicating a branch prediction error, the address of the erroneous branch instruction and the actual jump target address carried in the broadcast signal are matched with the address of the branch instruction and the alternative path jump address in the data item of the unpredictable branch record, respectively. The instruction sequence buffer is configured as follows: Get the current instruction fetch address of the instruction fetch unit; In response to the current fetch address matching the alternative path jump address of at least one data item in the unpredictable branch record, and the previous fetch address of the current fetch address matching the address of the branch instruction of the data item, at least a portion of the instruction sequence sent by the fetch unit to the decoder is cached by bypass detection based on the feature information of the instruction sequence of the alternative path corresponding to the matched data item. as well as In response to the unpredictable branch record unit finding a data item whose address matches both the branch instruction address and the alternative path jump address, and the completion of the caching operation of the instruction sequence corresponding to the data item, the instruction sequence corresponding to the data item is injected into the decoder segment.

11. The apparatus according to claim 10, characterized in that, The unpredictable branch record unit is configured as follows: In response to a branch prediction error, the unpredictable branch record is updated based on the branch instruction commit information provided by the commit segment. The unpredictable branch record includes multiple data items, each of which includes at least the address of the corresponding branch instruction, the address of the corresponding alternative path jump, and the count of the branch instruction prediction error. In response to the count in the data item of the unpredictable branch record reaching a first threshold when updating the data item, the branch instruction of the data item is taken as the target branch instruction.

12. The apparatus according to claim 11, characterized in that, The characteristic information of the instruction sequence of the candidate path corresponding to the branch instruction is the offset mapping, which records the address offset sequence between adjacent instructions in the instruction sequence of the candidate path.

13. The apparatus according to claim 12, characterized in that, The instruction sequence buffer is configured as follows: The address offset between adjacent instructions sent by the instruction fetch unit to the decode segment is compared with the offset at the corresponding position in the offset mapping; In response to a match, cache the current instruction; In response to a mismatch, the cache operation is completed and the trajectory end address is updated to the current fetch address.

14. The apparatus according to claim 13, characterized in that, The instruction sequence buffer is configured as follows: In response to the unpredictable branch record unit finding a data item that matches both the address of the branch instruction and the jump address of the alternative path, and completing the caching operation of the instruction sequence of the alternative path, a pause signal is sent to the instruction fetch unit to prevent the instruction fetch unit from initiating a new instruction fetch request to the instruction cache. Send the cached sequence of instructions for the alternative paths to the decoder segment; The updated trajectory end address is sent as the new instruction fetch address to the instruction fetch unit to resume operation of the instruction fetch unit.

15. The apparatus according to claim 11, characterized in that, The unpredictable branch record unit is configured as follows: Based on the address of the target branch instruction and the alternative path jump address of the target branch instruction, query the matching data item in the unpredictable branch record; In response to finding a matching data item, update the count of the matching data items; In response to finding a partially matching data item, the address of the target branch instruction and the alternative path jump address of the target branch instruction are recorded in an allocated data item, and the corresponding count is initialized; wherein, the partially matching data item is a data item in which the address of the branch instruction matches the address of the target branch instruction, but the alternative path jump address does not match the alternative path jump address of the target branch instruction.

16. The apparatus according to claim 15, characterized in that, The unpredictable branch record has a predetermined number of data items; The unpredictable branch record unit is configured as follows: In response to the existence of a free data item, a free data item is allocated, and the address of the target branch instruction and the alternative path jump address of the target branch instruction are recorded in the free data item; In response to the absence of a free data item, a low-count data item is cleared and allocated to the target branch instruction, and the address of the target branch instruction and the alternative path jump address of the target branch instruction are recorded in the allocated data item.

17. The apparatus according to claim 10, characterized in that, The instructions in the cached instruction sequence are raw instructions that have not been decoded.

18. The apparatus according to claim 10, characterized in that, The data items for unpredictable branch records also include branch mappings, which record the jump direction information of each branch instruction within the alternative paths; The unpredictable branch record unit is also configured as follows: The branch history register of the branch predictor is incrementally updated according to the branch mapping.

19. An out-of-order execution processor, characterized in that, include: Branch prediction unit; Instruction fetch unit; Decoded segment; Rename the section; Launch queue; Submission segment; Execution unit; as well as The out-of-order execution pipeline control device as described in any one of claims 10-18.