Method, device, equipment and storage medium for predicting branch instruction execution results

By using the branch target buffer to obtain entries from the current and historical clock cycles after the processor pipeline flushing event to predict branch instructions, the pipeline cavitation problem is solved and the processor's efficiency is improved.

CN118605950BActive Publication Date: 2024-11-01BEIJING INSTITUTE OF OPEN SOURCE CHIP
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411053488.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-01
Publication Date
2024-11-01
Estimated Expiration
2044-08-01

AI Technical Summary

Technical Problem

After a flush event occurs in the processor pipeline, the previously read entries are cleared, causing cavitation in the processor pipeline and making it impossible to predict the execution results of branch instructions in a timely manner.

Method used

Within a preset time period after a flush event occurs in the processor pipeline, the target entries of the branch instructions expected to be predicted in the current clock cycle are obtained using the first branch target buffer, and the corresponding prediction entries are obtained by combining the branch target buffers of historical clock cycles, so as to obtain and execute the prediction results of the branch instructions.

Benefits of technology

This reduces the time spent in the processor pipeline with cavitation, improving processor efficiency and overall performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118605950B_ABST
    Figure CN118605950B_ABST
Patent Text Reader

Abstract

The present application provides a method, apparatus, device and storage medium for predicting the execution result of a branch instruction, and relates to the field of branch instruction technology. Since the first branch target buffer is used to update the execution result of a new branch instruction to a table entry corresponding to the new branch instruction, and in a first time period (for example, within a preset time length after a flush event occurs in the pipeline of the processor), the starting address of the first branch instruction to be predicted in the current clock cycle is used to obtain the first target table entry in the preset first branch target buffer, and the first target table entry is determined as the prediction table entry corresponding to the first branch instruction, and then the prediction result of the execution of the first branch instruction is obtained according to the prediction table entry, so as to execute the first branch instruction according to the prediction result, without waiting until the future clock cycle to make the first prediction, thereby reducing the duration of bubbles in the pipeline of the processor.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of branch instruction technology, and in particular to a method, device, equipment and storage medium for predicting branch instruction execution results. Background Art

[0002] The branch target buffer (BTB) is used to store the execution results of branch instructions, such as the jump address and jump result of the branch instruction. The processor predicts the execution results of the branch instruction through the branch target buffer.

[0003] In the prior art, the look-ahead pipelining technique is used to predict the execution result of a branch instruction, that is, in the current clock cycle, the execution result of the current branch instruction to be predicted is predicted based on the table entries previously read from the branch target buffer, and at the same time, the table entries of future branch instructions are read from the branch target buffer based on the starting address of the current branch instruction to be predicted, so that the execution result of the branch instruction can be predicted in the future clock cycle based on the table entries previously read.

[0004] In the process of implementing the present application, the inventors discovered that there are at least the following problems in the prior art: after a flush event occurs in the processor's pipeline (pipeline clearing), since the previously read table entries are cleared, it is necessary to read the table entries of future branch instructions from the branch target buffer according to the starting address of the current branch instruction to be predicted in the first clock cycle, so as to make the first prediction of the execution result of the branch instruction in the future clock cycle, resulting in a bubble in the processor's pipeline before the clock cycle for the first prediction, that is, the processor's pipeline is idle without performing any effective work. Summary of the invention

[0005] The embodiments of the present application provide a method, device, equipment and storage medium for predicting the execution result of a branch instruction to solve the problem of cavitation in the pipeline of a processor after a flush event occurs in the pipeline of the processor in the prior art.

[0006] In a first aspect, an embodiment of the present application provides a method for predicting a branch instruction execution result, the method comprising:

[0007] When the current clock cycle belongs to the first time period, according to the starting address of the first branch instruction to be predicted in the current clock cycle, a first target table entry in a preset first branch target buffer is obtained, and the first target table entry is determined as a prediction table entry corresponding to the first branch instruction, and:

[0008] When the current clock cycle belongs to the second time period, a second target table entry obtained from a preset second branch target buffer in a historical clock cycle according to a starting address of a historical second branch instruction to be predicted is determined as a prediction table entry corresponding to the first branch instruction;

[0009] According to the prediction table entry, obtaining a prediction result of the execution of the first branch instruction, so as to execute the first branch instruction according to the prediction result;

[0010] Among them, the first branch target buffer is used to update the execution result of the new branch instruction to the table entry corresponding to the new branch instruction; the second branch target buffer is used to update the execution result of the branch instruction executed later to the table entry corresponding to the branch instruction executed earlier.

[0011] In a second aspect, an embodiment of the present application further provides a device for predicting a branch instruction execution result, the device comprising:

[0012] A first determination module is configured to obtain, when a current clock cycle belongs to a first time period, a first target table entry in a preset first branch target buffer according to a start address of a first branch instruction to be predicted in the current clock cycle, and determine the first target table entry as a prediction table entry corresponding to the first branch instruction, and:

[0013] A second determination module is used to determine, when the current clock cycle belongs to a second time period, a second target table entry obtained from a preset second branch target buffer in a historical clock cycle according to a starting address of a historical second branch instruction to be predicted as a prediction table entry corresponding to the first branch instruction;

[0014] A prediction module, configured to obtain a prediction result of the execution of the first branch instruction according to the prediction table entry, so as to execute the first branch instruction according to the prediction result;

[0015] Among them, the first branch target buffer is used to update the execution result of the new branch instruction to the table entry corresponding to the new branch instruction; the second branch target buffer is used to update the execution result of the branch instruction executed later to the table entry corresponding to the branch instruction executed earlier.

[0016] In a third aspect, an embodiment of the present application further provides an electronic device, including a processor;

[0017] a memory for storing instructions executable by the processor;

[0018] The processor is configured to execute the instructions to implement the method of the first aspect.

[0019] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, which, when instructions in the computer-readable storage medium are executed by a processor of an electronic device, enables the electronic device to execute the method of the first aspect.

[0020] In an embodiment of the present application, since the first branch target buffer is used to update the execution result of the new branch instruction to the table entry corresponding to the new branch instruction, and in a first time period (for example, within a preset time length after a flush event occurs in the processor's pipeline), the starting address of the first branch instruction to be predicted in the current clock cycle is used to obtain the first target table entry in the preset first branch target buffer, and the first target table entry is determined as the prediction table entry corresponding to the first branch instruction, and then the prediction result of the execution of the first branch instruction is obtained according to the prediction table entry, so as to execute the first branch instruction according to the prediction result, without having to wait until the future clock cycle to make the first prediction, thereby reducing the duration of bubbles in the processor's pipeline.

[0021] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0023] Figure 1 It is a flowchart of a method for predicting the execution result of a branch instruction provided by an embodiment of the present invention;

[0024] Figure 2 It is a flowchart of another method for predicting the execution result of a branch instruction provided by an embodiment of the present invention;

[0025] Figure 3 It is a block diagram of a device for predicting the execution result of a branch instruction provided by an embodiment of the present invention;

[0026] Figure 4 is a block diagram of an electronic device provided by an embodiment of the present invention;

[0027] Figure 5 is a block diagram of another electronic device according to another embodiment of the present invention. DETAILED DESCRIPTION

[0028] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0029] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally a class, and the number of objects is not limited. For example, the first object can be one or more. In addition, the term "and / or" in the specification and claims is used to describe the association relationship of associated objects, indicating that three kinds of relationships can exist, for example, A and / or B can be represented: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the front and back associated objects are a kind of "or" relationship. In the embodiment of the present application, the term "multiple" refers to two or more, and other quantifiers are similar.

[0030] The following is a detailed description of the method for predicting the execution result of a branch instruction provided in the embodiment of the present application through specific embodiments and application scenarios in conjunction with the accompanying drawings.

[0031] Figure 1 is a flowchart of a method for predicting the execution result of a branch instruction provided in an embodiment of the present application. Figure 1 As shown, the method may include:

[0032] Step 101. When the current clock cycle belongs to the first time period, obtain the first target table entry in the preset first branch target buffer according to the starting address of the first branch instruction to be predicted in the current clock cycle, and determine the first target table entry as the prediction table entry corresponding to the first branch instruction.

[0033] The first branch target buffer is used to update the execution result of the new branch instruction into the table entry corresponding to the new branch instruction.

[0034] In an embodiment of the present application, when the current clock cycle belongs to the first time period, the first target table entry in the preset first branch target buffer is obtained according to the starting address of the first branch instruction to be predicted in the current clock cycle, and the first target table entry is determined as the prediction table entry corresponding to the first branch instruction, and then the prediction result of the execution of the first branch instruction is obtained according to the prediction table entry.

[0035] It should be noted that the clock cycle is the clock cycle of the processor, and the first branch instruction is the branch instruction expected to be predicted in the current clock cycle. The first branch target buffer is a branch target buffer, and a plurality of table entries are stored in the branch target buffer. One table entry in the branch target buffer stores the execution result of a branch instruction and the label information of the branch instruction, wherein the execution result of the branch instruction includes the jump address of the branch instruction. In other embodiments, the execution result of the branch instruction includes the jump address of the branch instruction and the jump result of the branch instruction, and the jump result of the branch instruction includes two types: jump and no jump.

[0036] The first branch target buffer is also used to update the label information of the new branch instruction into the table entry corresponding to the new branch instruction.

[0037] The table entry corresponding to the branch instruction is the table entry corresponding to the starting address of the branch instruction, and the address of the table entry corresponding to the branch instruction is the index address of the table entry mapped according to the starting address of the branch instruction.

[0038] Specifically, in some embodiments, the first time period may be a time period within a preset duration after a flush event occurs in the processor pipeline, wherein the preset duration may be pre-set according to demand, for example, the preset duration may be one clock cycle, two clock cycles, etc.

[0039] For example, in the processor's clock cycle A1, after the branch instruction B1 is executed, the execution result of the branch instruction B1 is stored in the table entry C1 corresponding to the starting address of the branch instruction B1; in the clock cycle A2 after the processor's clock cycle A1, the first branch instruction predicted in the current clock cycle is the branch instruction B1, then according to the starting address of the branch instruction B1, the first target table entry in the first branch target buffer is obtained, the first target table entry is the table entry C1, and the table entry C1 is determined as the predicted table entry corresponding to the first branch instruction.

[0040] Similarly, for a new branch target buffer (FTB, Fetch Target buffer), when the current clock cycle belongs to the first time period, the first target instruction block table entry in the preset first new branch target buffer is obtained according to the starting address of the first branch instruction block to be predicted in the current clock cycle, and the first target instruction block table entry is determined as the predicted instruction block table entry corresponding to the first branch instruction block.

[0041] Among them, the first branch instruction block is a branch instruction block expected to be predicted in the current clock cycle, and one branch instruction block includes multiple branch instructions (for example, two branch instructions); the first new branch target buffer is a new branch target buffer, and the new branch target buffer stores multiple instruction block table entries, and one instruction block table entry stores an execution result of a branch instruction block and label information of the branch instruction block, and the execution result of the branch instruction block includes the execution result of each branch instruction in the branch instruction block; in other embodiments, the execution result of the branch instruction block includes the execution result of each branch instruction in the branch instruction block and the jump result of each branch instruction.

[0042] Step 102: When the current clock cycle belongs to the second time period, a second target table entry obtained from a preset second branch target buffer according to a starting address of a historically predicted second branch instruction in a historical clock cycle is determined as a prediction table entry corresponding to the first branch instruction.

[0043] The second branch target buffer is used to update the execution result of the branch instruction executed later to the table entry corresponding to the branch instruction executed earlier.

[0044] In an embodiment of the present application, when the current clock cycle belongs to the second time period, the second target table entry obtained from the preset second branch target buffer in the historical clock cycle according to the starting address of the second branch instruction to be predicted historically is determined as the prediction table entry corresponding to the first branch instruction, and then the prediction result of the execution of the first branch instruction is obtained according to the prediction table entry.

[0045] It should be noted that the second branch instruction is a branch instruction to be predicted in the history of the historical clock cycle; the second branch target buffer is a branch target buffer.

[0046] The historical clock cycle is a clock cycle before the current clock cycle, for example, the historical clock cycle is a clock cycle before the current clock cycle.

[0047] Specifically, in some embodiments, the second time period may be a time period before the flush event occurs in the pipeline and other than a preset time period after the flush event occurs in the pipeline, that is, the second time period includes a time period other than a preset time period after the flush event occurs in the pipeline of the processor.

[0048] The second branch target buffer is also used to update the tag information of the branch instruction executed later into the table entry corresponding to the branch instruction executed earlier.

[0049] For example, in clock cycle A3 of the processor, after the branch instruction B2 is executed, the execution result of the branch instruction B2 is stored in the table entry C3 corresponding to the starting address of the branch instruction B3, wherein the branch instruction B3 is the branch instruction executed in the clock cycle A4 before the clock cycle A3; in clock cycle A5 after the clock cycle A3 of the processor, the branch instruction expected to be predicted in the current clock cycle is the branch instruction B3, then according to the starting address of the branch instruction B3, the table entry C3 corresponding to the starting address of the branch instruction B3 is obtained; in clock cycle A6 after clock cycle A5, the first branch instruction expected to be predicted in the current clock cycle is the branch instruction B2, the historical clock cycle is clock cycle A5, and the second branch instruction to be predicted in the historical clock cycle according to history is the branch instruction B3, then the second target table entry is table entry C3, and table entry C3 is determined as the predicted table entry corresponding to the first branch instruction.

[0050] In clock cycle A2 after clock cycle A1 of the processor, the first branch instruction predicted in the current clock cycle is branch instruction B1. Then, according to the starting address of branch instruction B1, the first target table entry in the first branch target buffer is obtained. The first target table entry is table entry C1, and table entry C1 is determined as the predicted table entry corresponding to the first branch instruction.

[0051] Similarly, for the new branch target buffer, when the current clock cycle belongs to the second time period, the second target instruction block table entry obtained from the preset second new branch target buffer according to the starting address of the second branch instruction block to be predicted in the historical clock cycle is determined as the predicted instruction block table entry corresponding to the first branch instruction block. The second branch instruction block is the branch instruction block to be predicted in the historical clock cycle; the second new branch target buffer is a new type of branch target buffer.

[0052] Step 103: Obtain a prediction result of the execution of the first branch instruction according to the prediction table entry, so as to execute the first branch instruction according to the prediction result.

[0053] In an embodiment of the present application, a predicted result of the execution of the first branch instruction is obtained according to a prediction table entry, so that the first branch instruction is executed according to the predicted result, and in this process, the duration of the pipeline cavitation of the processor is effectively reduced.

[0054] It should be noted that, when the tag information in the prediction table entry is the same as the tag information of the first branch instruction, the predicted result of executing the first branch instruction may be the execution result of the branch instruction in the prediction table entry.

[0055] Similarly, for the new branch target buffer, the instruction block execution prediction result of the first branch instruction block is obtained according to the predicted instruction block table entry, so that the processor can execute the first branch instruction block according to the instruction block execution prediction result.

[0056] To summarize, in an embodiment of the present application, since the first branch target buffer is used to update the execution result of the new branch instruction to the table entry corresponding to the new branch instruction, and in a first time period (for example, within a preset time length after a flush event occurs in the pipeline of the processor), the starting address of the first branch instruction to be predicted in the current clock cycle is used to obtain the first target table entry in the preset first branch target buffer, and the first target table entry is determined as the prediction table entry corresponding to the first branch instruction, and then the prediction result of the execution of the first branch instruction is obtained according to the prediction table entry, so as to execute the first branch instruction according to the prediction result, without having to wait until the future clock cycle to make the first prediction, thereby reducing the duration of bubbles in the pipeline of the processor.

[0057] Figure 2 is a flowchart of the specific steps of a method for predicting the execution result of a branch instruction provided in an embodiment of the present application, such as Figure 2 As shown, the method may include:

[0058] Step 201: When the current clock cycle belongs to the first time period, obtain the first target table entry in the preset first branch target buffer according to the starting address of the first branch instruction to be predicted in the current clock cycle, and determine the first target table entry as the prediction table entry corresponding to the first branch instruction.

[0059] The first branch target buffer is used to update the execution result of the new branch instruction into the table entry corresponding to the new branch instruction.

[0060] The implementation of this step is similar to the implementation process of the above sub-step 101, and will not be repeated here.

[0061] Optionally, in some embodiments, acquiring the first target table entry in the preset first branch target buffer according to the start address of the first branch instruction to be predicted in the current clock cycle includes the following sub-steps:

[0062] Sub-step 2011: Map the starting address of the first branch instruction to the first target address of the first target table entry.

[0063] In an embodiment of the present application, the starting address of the first branch instruction is mapped to the first target address of the first target table entry, and then the entry in the first branch target buffer whose address is the same as the first target address is determined as the first target table entry.

[0064] It should be noted that the first target address is the index address of the first target table entry.

[0065] Optionally, in some embodiments, sub-step 2011 may include the following molecular steps:

[0066] Molecular step 2011a, obtaining the first target address according to the starting address of the first branch instruction and the jump information of the historical branch instructions in the current clock cycle.

[0067] In an embodiment of the present application, the first target address is obtained based on the starting address of the first branch instruction and the jump information of the historical branch instruction in the current clock cycle, and then the table entry in the first branch target buffer whose address is the same as the first target address is determined as the first target table entry.

[0068] It should be noted that the jump information of the historical branch instruction in the current clock cycle may be the jump result of the historical branch instruction executed in the clock cycle before the current clock cycle, whose starting address is the same as the starting address of the first branch instruction. The jump information of the historical branch instruction is used to characterize a jump or no jump. For example, binary 1 represents a jump and binary 0 represents no jump. Then the jump information of the historical branch instruction includes two types: binary 1 and binary 0.

[0069] Specifically, after address calculation is performed on the start address of the first branch instruction and the jump information of the historical branch instruction in the current clock cycle, the first target address is obtained through mapping.

[0070] Sub-step 2012: determine, in the first branch target buffer, an entry having the same address as the first target address as the first target entry.

[0071] In an embodiment of the present application, the first target entry is determined as the prediction entry corresponding to the first branch instruction by determining the entry in the first branch target buffer whose address (index address) is the same as the first target address as the first target entry.

[0072] By executing sub-steps 2011 to 2012, it is possible to obtain the first target table entry.

[0073] Similarly, for the new branch target buffer, the starting address of the first branch instruction block is mapped to the index address of the first target instruction block table entry. For example, based on the starting address of the first branch instruction block and the jump information of the historical branch instruction block in the current clock cycle, the index address of the first target instruction block table entry is obtained, and then the instruction block table entry in the first new branch target buffer whose index address is the same as the index address of the first target instruction block table entry is determined as the first target instruction block table entry.

[0074] Step 202: When the current clock cycle belongs to the second time period, the second target table entry obtained from the preset second branch target buffer in the historical clock cycle according to the starting address of the historical second branch instruction to be predicted is determined as the prediction table entry corresponding to the first branch instruction.

[0075] The second branch target buffer is used to update the execution result of the branch instruction executed later to the table entry corresponding to the branch instruction executed earlier.

[0076] The implementation of this step is similar to the implementation process of the above sub-step 102, and will not be repeated here.

[0077] Optionally, in some embodiments, the capacity of the table entries of the first branch target buffer is smaller than the capacity of the table entries of the second branch target buffer.

[0078] In an embodiment of the present application, the first branch target buffer is a small-capacity, low-latency, fully associative BTB, and the second branch target buffer is a large-capacity, high-throughput BTB using look-ahead pipeline technology. Among them, fully associative refers to a cache design in which each cache entry (table entry) can be accessed (i.e., "hit") without being restricted by its physical location. In a fully associative BTB, this means that the address of any branch instruction can be mapped to any entry (table entry) in the fully associative BTB.

[0079] The first branch target buffer makes up for the problem of missing prediction results caused by long access delay and low connectivity of the second branch target buffer, and the second branch target buffer fully maintains the large capacity advantage of the look-ahead pipeline technology structure. This design has an access delay close to that of a traditional small-capacity, fully associative BTB when the processor's pipeline is cleared, and its capacity and accuracy during normal access (especially when the connectivity is insufficient) exceed those of a typical look-ahead pipeline technology BTB. This combined design has the advantages of both.

[0080] By improving the predictor capacity and accuracy, the instruction supply capability of the processor front end can be enhanced, thereby contributing to the overall performance of the processor; by reducing the access delay caused by pipeline flushing, the time the processor waits can be reduced, allowing more time to complete actual calculations, thereby improving the overall performance of the processor.

[0081] Step 203: When the tag information in the prediction table entry is the same as the tag information of the first branch instruction, determine the jump address and jump result in the prediction table entry as the predicted result of the execution of the first branch instruction.

[0082] In an embodiment of the present application, when the label information in the prediction table entry is the same as the label information of the first branch instruction, the jump address and jump result in the prediction table entry are determined as the prediction result, and then the first branch instruction is executed according to the prediction result.

[0083] Step 204: When the jump result in the prediction table entry is a jump, a read instruction operation is performed from the storage space pointed to by the jump address in the prediction table entry.

[0084] In the embodiment of the present application, when the jump result in the prediction table entry is a jump, a read instruction operation is performed from the storage space pointed to by the jump address in the prediction table entry to execute the first branch instruction.

[0085] Step 205: When the jump result in the prediction table entry is no jump, read the next instruction of the first branch instruction.

[0086] In the embodiment of the present application, the first branch instruction is executed by reading the next instruction of the first branch instruction when the jump result in the prediction table entry is not to jump.

[0087] Similarly, for the new branch target buffer, when the label information in the predicted instruction block table entry is the same as the label information of the first branch instruction block, the jump address and jump result of each branch instruction in the predicted instruction block table entry are determined as the instruction block execution prediction result, and then when the jump result of the branch instruction in the predicted instruction block table entry is a jump, the instruction operation is read from the storage space pointed to by the jump address of the branch instruction in the predicted instruction block table entry; when the jump result of each branch instruction in the predicted instruction block table entry is no jump, the next instruction block of the first branch instruction block is read.

[0088] Optionally, in some embodiments, the method further comprises the following steps:

[0089] Step 206: In the historical clock cycle, map the start address of the second branch instruction to the second target address of the second target table entry.

[0090] In an embodiment of the present application, the starting address of the second branch instruction is mapped to the second target address of the second target table entry in the historical clock cycle, and then the entry in the second branch target buffer with the same address as the second target address is determined as the second target table entry.

[0091] It should be noted that the second target address is the index address of the second target table entry.

[0092] Optionally, in some embodiments, step 206 may include the following sub-steps:

[0093] Sub-step 2061: In the historical clock cycle, according to the starting address of the second branch instruction and the jump information of the historical branch instruction in the historical clock cycle, obtain the second target address.

[0094] In an embodiment of the present application, the second target address is obtained according to the starting address of the second branch instruction and the jump information of the historical branch instruction in the historical clock cycle in the historical clock cycle, and then the table entry in the second branch target buffer whose address is the same as the second target address is determined as the second target table entry.

[0095] It should be noted that the jump information of the historical branch instruction in the historical clock cycle may be the jump result of the historical branch instruction executed in the clock cycle before the historical clock cycle, whose starting address is the same as the starting address of the second branch instruction.

[0096] Specifically, the start address of the second branch instruction and the jump information of the historical branch instruction in the historical clock cycle are subjected to address calculation, and then mapped to obtain the second target address.

[0097] Step 207: Determine the entry in the second branch target buffer whose address is the same as the second target address as the second target entry.

[0098] In an embodiment of the present application, the entry in the second branch target buffer whose address (index address) is the same as the second target address is determined as the second target entry, and then the second target entry is determined as the prediction entry corresponding to the first branch instruction.

[0099] By executing step 206 to step 207, it is possible to obtain the second target entry.

[0100] Similarly, for the new branch target buffer, in the historical clock cycle, the starting address of the second branch instruction block is mapped to the index address of the second target instruction block table entry. For example, in the historical clock cycle, the index address of the second target instruction block table entry is obtained based on the starting address of the second branch instruction block and the jump information of each branch instruction in the historical branch instruction block in the historical clock cycle, and then the instruction block table entry in the second new branch target buffer whose index address is the same as the index address of the second target instruction block table entry is determined as the second target instruction block table entry.

[0101] Optionally, in some embodiments, the method further comprises the following steps:

[0102] Step 208. During the first time period, the execution result of the new branch instruction is updated to the table entry corresponding to the new branch instruction in the first branch target buffer, and the execution result of the new branch instruction is updated to the table entry corresponding to the branch instruction executed earlier than the new branch instruction in the second branch target buffer.

[0103] In an embodiment of the present application, the execution result of the new branch instruction is updated to the table entry corresponding to the new branch instruction in the first branch target buffer within a first time period, and the execution result of the new branch instruction is updated to the table entry corresponding to the branch instruction executed earlier than the new branch instruction in the second branch target buffer, so as to realize the update of the table entry of the first branch target buffer and the update of the table entry of the second branch target buffer.

[0104] Step 209: During the second time period, update the execution result of the new branch instruction to the entry corresponding to the branch instruction executed earlier than the new branch instruction in the second branch target buffer.

[0105] In an embodiment of the present application, the table entry of the second branch target buffer is updated by updating the execution result of the new branch instruction to the table entry corresponding to the branch instruction executed earlier than the new branch instruction in the second time period.

[0106] By executing step 208 to step 209 , it is possible to update the table entries of the first branch target buffer and the second branch target buffer.

[0107] Similarly, for the new branch target buffer, within the first time period, the execution result of the new branch instruction block is updated to the table entry corresponding to the new branch instruction block in the first new branch target buffer, and the execution result of the new branch instruction block is updated to the table entry corresponding to the branch instruction block executed earlier than the new branch instruction block in the second new branch target buffer; within the second time period, the execution result of the new branch instruction block is updated to the table entry corresponding to the branch instruction block executed earlier than the new branch instruction block in the second new branch target buffer.

[0108] Optionally, in some embodiments, before step 203, the method further includes the following steps:

[0109] Step 210: In the historical clock cycle, according to the start address of the second branch instruction to be predicted in the history, obtain the second target table entry in the second branch target buffer.

[0110] In an embodiment of the present application, by obtaining the second target table entry in the second branch target buffer according to the starting address of the second branch instruction to be predicted in the historical clock cycle, and then obtaining the first target table entry in the first branch target buffer according to the starting address of the first branch instruction to be predicted in the current clock cycle, the prediction table entry is determined from the first target table entry and the second target table entry according to preset conditions.

[0111] Step 211: Obtain a first target entry in the first branch target buffer according to the start address of the first branch instruction to be predicted in the current clock cycle.

[0112] In an embodiment of the present application, the first target table entry in the first branch target buffer is obtained by predicting the starting address of the first branch instruction according to the current clock cycle, and then determining the predicted table entry from the first target table entry and the second target table entry according to preset conditions.

[0113] Step 212: Determine the predicted entry from the first target entry and the second target entry according to a preset condition.

[0114] In the embodiment of the present application, a prediction table entry is determined from the first target table entry and the second target table entry according to a preset condition, and then a prediction result of the execution of the first branch instruction is obtained according to the prediction table entry.

[0115] Optionally, in some embodiments, step 212 may include the following sub-steps:

[0116] Sub-step 2121: When the tag information in the first target table entry is the same as the tag information of the first branch instruction, and the tag information in the second target table entry is the same as the tag information of the first branch instruction, determine the first target table entry as the predicted table entry.

[0117] In an embodiment of the present application, when the label information in the first target table entry is the same as the label information of the first branch instruction, and the label information in the second target table entry is the same as the label information of the first branch instruction, the first target table entry is determined as a predicted table entry, and then the predicted result of the execution of the first branch instruction is obtained based on the predicted table entry.

[0118] Sub-step 2122: When the tag information in the first target table entry is the same as the tag information of the first branch instruction, and the tag information in the second target table entry is different from the tag information of the first branch instruction, determine the first target table entry as the predicted table entry.

[0119] In an embodiment of the present application, when the label information in the first target table entry is the same as the label information of the first branch instruction and the label information in the second target table entry is different from the label information of the first branch instruction, the first target table entry is determined as a predicted table entry, and then the predicted result of the execution of the first branch instruction is obtained based on the predicted table entry.

[0120] Sub-step 2123: When the tag information in the first target table entry is different from the tag information of the first branch instruction, and the tag information in the second target table entry is the same as the tag information of the first branch instruction, determine the second target table entry as the predicted table entry.

[0121] In an embodiment of the present application, when the label information in the first target table entry is different from the label information of the first branch instruction and the label information in the second target table entry is the same as the label information of the first branch instruction, the second target table entry is determined as a prediction table entry, and then the prediction result of the execution of the first branch instruction is obtained based on the prediction table entry.

[0122] By executing sub-steps 2121 to 2123, it can be achieved that, when the first branch target buffer hits (the label information in the first target table entry is the same as the label information of the first branch instruction), the first target table entry in the first branch target buffer is preferentially selected as the prediction table entry for the first branch instruction to improve the accuracy of the prediction result of the execution of the first branch instruction.

[0123] By executing steps 210 to 212 , it is possible to determine the prediction table entry.

[0124] Similarly, for the new branch target buffer, in the historical clock cycle, the second target instruction block table entry in the second new branch target buffer is obtained based on the starting address of the second branch instruction block to be predicted in the history, and then the first target instruction block table entry in the first new branch target buffer is obtained based on the starting address of the first branch instruction block to be predicted in the current clock cycle, and then according to the preset conditions, the predicted instruction block table entry is determined from the first target instruction block table entry and the second target instruction block table entry.

[0125] Specifically, when the label information in the first target instruction block table entry is the same as the label information of the first branch instruction block, and the label information in the second target instruction block table entry is the same as the label information of the first branch instruction block, the first target instruction block table entry is determined as a predicted instruction block table entry; when the label information in the first target instruction block table entry is the same as the label information of the first branch instruction block, and the label information in the second target instruction block table entry is different from the label information of the first branch instruction block, the first target instruction block table entry is determined as a predicted instruction block table entry; when the label information in the first target instruction block table entry is different from the label information of the first branch instruction block, and the label information in the second target instruction block table entry is the same as the label information of the first branch instruction block, the second target instruction block table entry is determined as a predicted instruction block table entry.

[0126] Optionally, in some embodiments, the method further comprises the following steps:

[0127] Step 213: Update the execution result of the new branch instruction into the table entry corresponding to the branch instruction executed earlier than the new branch instruction in the second branch target buffer.

[0128] In the embodiment of the present application, the table entry of the second branch target buffer is updated by updating the execution result of the new branch instruction to the table entry corresponding to the branch instruction executed earlier than the new branch instruction in the second branch target buffer.

[0129] Step 214, when the table entry corresponding to the branch instruction executed earlier than the new branch instruction is updated to the second branch target buffer by replacing the old table entry in the second branch target buffer, the execution result of the new branch instruction is updated to the table entry corresponding to the new branch instruction in the first branch target buffer.

[0130] In an embodiment of the present application, by updating the table entry corresponding to the branch instruction executed earlier than the new branch instruction to the second branch target buffer by replacing the old table entry in the second branch target buffer, the execution result of the new branch instruction is updated to the table entry corresponding to the new branch instruction in the first branch target buffer, so as to realize the update of the table entry of the first branch target buffer.

[0131] By executing step 213 to step 214 , it is possible to update the table entries of the second branch target buffer and the table entries of the first branch target buffer.

[0132] Similarly, for the new branch target buffer, the execution result of the new branch instruction block is first updated to the instruction block table entry corresponding to the branch instruction block executed earlier than the new branch instruction block in the second new branch target buffer, and then the instruction block table entry corresponding to the branch instruction block executed earlier than the new branch instruction block is updated to the second new branch target buffer by replacing the old instruction block table entry in the second new branch target buffer, and the execution result of the new branch instruction block is updated to the instruction block table entry corresponding to the new branch instruction block in the first new branch target buffer.

[0133] To summarize, in an embodiment of the present application, since the first branch target buffer is used to update the execution result of the new branch instruction to the table entry corresponding to the new branch instruction, and in a first time period (for example, within a preset time length after a flush event occurs in the pipeline of the processor), the starting address of the first branch instruction to be predicted in the current clock cycle is used to obtain the first target table entry in the preset first branch target buffer, and the first target table entry is determined as the prediction table entry corresponding to the first branch instruction, and then the prediction result of the execution of the first branch instruction is obtained according to the prediction table entry, so as to execute the first branch instruction according to the prediction result, without having to wait until the future clock cycle to make the first prediction, thereby reducing the duration of bubbles in the pipeline of the processor.

[0134] refer to Figure 3 , which shows a device for predicting the execution result of a branch instruction provided in an embodiment of the present application, the device comprising:

[0135] The first determination module 301 is configured to, when the current clock cycle belongs to the first time period, obtain a first target table entry in a preset first branch target buffer according to the start address of the first branch instruction to be predicted in the current clock cycle, and determine the first target table entry as a prediction table entry corresponding to the first branch instruction, and:

[0136] A second determination module 302 is configured to determine, when the current clock cycle belongs to a second time period, a second target table entry obtained from a preset second branch target buffer in a historical clock cycle according to a start address of a historical second branch instruction to be predicted as a prediction table entry corresponding to the first branch instruction;

[0137] A prediction module 303, configured to obtain a prediction result of the execution of the first branch instruction according to the prediction table entry, so as to execute the first branch instruction according to the prediction result;

[0138] Among them, the first branch target buffer is used to update the execution result of the new branch instruction to the table entry corresponding to the new branch instruction; the second branch target buffer is used to update the execution result of the branch instruction executed later to the table entry corresponding to the branch instruction executed earlier.

[0139] Optionally, the first determining module 301 specifically includes:

[0140] A mapping submodule, used for mapping the starting address of the first branch instruction to the first target address of the first target table entry;

[0141] The first determining submodule is used to determine a table entry in the first branch target buffer whose address is the same as the first target address as the first target table entry.

[0142] Optionally, the first mapping submodule specifically includes:

[0143] An acquisition unit is used to acquire the first target address according to the starting address of the first branch instruction and the jump information of the historical branch instructions in the current clock cycle.

[0144] Optionally, the device further comprises:

[0145] A mapping module, configured to map the start address of the second branch instruction to a second target address of the second target table entry in the historical clock cycle;

[0146] The third determination module is used to determine the entry in the second branch target buffer whose address is the same as the second target address as the second target entry.

[0147] Optional, mapping module, including:

[0148] The acquisition submodule is used to acquire the second target address in the historical clock cycle according to the starting address of the second branch instruction and the jump information of the historical branch instruction in the historical clock cycle.

[0149] Optionally, the prediction module 303 specifically includes:

[0150] The second determining submodule is used to determine the jump address and jump result in the prediction table entry as the prediction result when the tag information in the prediction table entry is the same as the tag information of the first branch instruction.

[0151] Optionally, the prediction module 303 specifically includes:

[0152] A first reading submodule, configured to, when the jump result in the prediction table entry is a jump, perform a reading instruction operation from a storage space pointed to by a jump address in the prediction table entry;

[0153] The second reading submodule is used to read the next instruction of the first branch instruction when the jump result in the prediction table entry is not to jump.

[0154] Optionally, the device further comprises:

[0155] A first updating module, configured to update, within the first time period, the execution result of the new branch instruction into a table entry corresponding to the new branch instruction in the first branch target buffer, and update the execution result of the new branch instruction into a table entry corresponding to a branch instruction executed earlier than the new branch instruction in the second branch target buffer;

[0156] The second updating module is used to update the execution result of the new branch instruction to the table entry corresponding to the branch instruction executed earlier than the new branch instruction in the second branch target buffer within the second time period.

[0157] Optionally, the device further comprises:

[0158] A first acquisition module is used to acquire a second target table entry in the second branch target buffer according to a start address of a historical second branch instruction to be predicted in the historical clock cycle;

[0159] A second acquisition module, configured to acquire a first target table entry in the first branch target buffer according to a start address of the first branch instruction to be predicted in the current clock cycle;

[0160] A fourth determination module is used to determine the predicted table item from the first target table item and the second target table item according to a preset condition.

[0161] Optionally, the fourth determining module specifically includes:

[0162] a third determination submodule, configured to determine the first target table entry as the prediction table entry when the label information in the first target table entry is the same as the label information of the first branch instruction, and the label information in the second target table entry is the same as the label information of the first branch instruction;

[0163] a fourth determination submodule, configured to determine the first target table entry as the predicted table entry when the label information in the first target table entry is the same as the label information of the first branch instruction and the label information in the second target table entry is different from the label information of the first branch instruction;

[0164] The fifth determination submodule is used to determine the second target table entry as the predicted table entry when the label information in the first target table entry is different from the label information of the first branch instruction and the label information in the second target table entry is the same as the label information of the first branch instruction.

[0165] Optionally, the device further comprises:

[0166] a third updating module, configured to update the execution result of the new branch instruction into a table entry corresponding to a branch instruction executed earlier than the new branch instruction in the second branch target buffer;

[0167] A fourth update module is used to update the execution result of the new branch instruction into the table entry corresponding to the new branch instruction in the first branch target buffer when the table entry corresponding to the branch instruction executed earlier than the new branch instruction is updated to the second branch target buffer by replacing the old table entry in the second branch target buffer.

[0168] Optionally, the capacity of the table entries of the first branch target buffer is smaller than the capacity of the table entries of the second branch target buffer.

[0169] In summary, in an embodiment of the present application, since the first branch target buffer is used to update the execution result of the new branch instruction to the table entry corresponding to the new branch instruction, and in a first time period (for example, within a preset time length after a flush event occurs in the pipeline of the processor), the starting address of the first branch instruction to be predicted in the current clock cycle is used to obtain the first target table entry in the preset first branch target buffer, and the first target table entry is determined as the prediction table entry corresponding to the first branch instruction, and then the prediction result of the execution of the first branch instruction is obtained according to the prediction table entry, so as to execute the first branch instruction according to the prediction result, without having to wait until the future clock cycle to make the first prediction, thereby reducing the duration of bubbles in the pipeline of the processor.

[0170] Figure 4 is a block diagram of an electronic device 600 according to an exemplary embodiment. For example, the electronic device 600 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.

[0171] Reference Figure 4 , the electronic device 600 may include one or more of the following components: a processing component 602 , a memory 604 , a power component 606 , a multimedia component 608 , an audio component 610 , an input / output (I / O) interface 612 , a sensor component 614 , and a communication component 616 .

[0172] The processing component 602 generally controls the overall operation of the electronic device 600, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 602 may include one or more processors 620 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 602 may include one or more modules to facilitate the interaction between the processing component 602 and other components. For example, the processing component 602 may include a multimedia module to facilitate the interaction between the multimedia component 608 and the processing component 602.

[0173] The memory 604 is used to store various types of data to support the operation of the electronic device 600. Examples of such data include instructions for any application or method operating on the electronic device 600, contact data, phone book data, messages, pictures, multimedia, etc. The memory 604 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.

[0174] The power supply component 606 provides power to the various components of the electronic device 600. The power supply component 606 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 600.

[0175] The multimedia component 608 includes a screen that provides an output interface between the electronic device 600 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 608 includes a front camera and / or a rear camera. When the electronic device 600 is in an operating mode, such as a shooting mode or a multimedia mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.

[0176] The audio component 610 is used to output and / or input audio signals. For example, the audio component 610 includes a microphone (MIC), and when the electronic device 600 is in an operation mode, such as a call mode, a recording mode, and a voice recognition mode, the microphone is used to receive an external audio signal. The received audio signal can be further stored in the memory 604 or sent via the communication component 616. In some embodiments, the audio component 610 also includes a speaker for outputting audio signals.

[0177] I / O interface 612 provides an interface between processing component 602 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: home button, volume button, start button, and lock button.

[0178] The sensor assembly 614 includes one or more sensors for providing various aspects of status assessment for the electronic device 600. For example, the sensor assembly 614 can detect the open / closed state of the electronic device 600, the relative positioning of the components, such as the display and keypad of the electronic device 600, and the sensor assembly 614 can also detect the position change of the electronic device 600 or a component of the electronic device 600, the presence or absence of contact between the user and the electronic device 600, the orientation or acceleration / deceleration of the electronic device 600, and the temperature change of the electronic device 600. The sensor assembly 614 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 614 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 614 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.

[0179] The communication component 616 is used to facilitate wired or wireless communication between the electronic device 600 and other devices. The electronic device 600 can access a wireless network based on a communication standard, such as WiFi, a carrier network (such as 2G, 3G, 4G or 5G), or a combination thereof. In an exemplary embodiment, the communication component 616 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 616 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.

[0180] In an exemplary embodiment, the electronic device 600 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to implement a method for predicting the execution result of a branch instruction provided in an embodiment of the present application.

[0181] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 604 including instructions, and the instructions can be executed by a processor 620 of an electronic device 600 to perform the above method. For example, the non-transitory storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0182] Figure 5 is a block diagram of an electronic device 700 according to an exemplary embodiment. For example, the electronic device 700 may be provided as a server. Figure 5 The electronic device 700 includes a processing component 722, which further includes one or more processors, and a memory resource represented by a memory 732, for storing instructions that can be executed by the processing component 722, such as an application. The application stored in the memory 732 may include one or more modules, each corresponding to a set of instructions. In addition, the processing component 722 is configured to execute instructions to perform a method for predicting the execution result of a branch instruction provided in an embodiment of the present application.

[0183] The electronic device 700 may also include a power supply component 726 configured to perform power management of the electronic device 700, a wired or wireless network interface 750 configured to connect the electronic device 700 to a network, and an input / output (I / O) interface 758. The electronic device 700 may operate based on an operating system stored in the memory 732, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™ or the like.

[0184] An embodiment of the present application also provides a computer program product, including a computer program, which implements the method for predicting the execution result of a branch instruction when the computer program is executed by a processor.

[0185] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the application disclosed herein. The present application is intended to cover any variations, uses or adaptations of the present application, which follow the general principles of the present application and include common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the following claims.

[0186] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.

[0187] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the protection scope of the present application.

[0188] The above is a detailed introduction to a method, device, electronic device and computer-readable storage medium for predicting the execution result of a branch instruction provided by the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for a person skilled in the art, according to the idea of ​​the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A method for predicting the execution result of a branch instruction, characterized in that: The method comprises: When the current clock cycle belongs to the first time period, according to the starting address of the first branch instruction to be predicted in the current clock cycle, a first target table entry in a preset first branch target buffer is obtained, and the first target table entry is determined as a prediction table entry corresponding to the first branch instruction, and: When the current clock cycle belongs to the second time period, a second target table entry obtained from a preset second branch target buffer in a historical clock cycle according to a starting address of a historical second branch instruction to be predicted is determined as a prediction table entry corresponding to the first branch instruction; According to the prediction table entry, obtaining a prediction result of the execution of the first branch instruction, so as to execute the first branch instruction according to the prediction result; Among them, the first branch target buffer is used to update the execution result of the new branch instruction to the table entry corresponding to the new branch instruction; the second branch target buffer is used to update the execution result of the branch instruction executed later to the table entry corresponding to the branch instruction executed earlier; the first time period is a time period within a preset time length after a flush event occurs in the pipeline of the processor; the second time period is a time period excluding the preset time length after a flush event occurs in the pipeline of the processor.

2. The method according to claim 1, characterized in that: The step of obtaining a first target entry in a preset first branch target buffer according to the start address of the first branch instruction to be predicted in the current clock cycle includes: Mapping the starting address of the first branch instruction to the first target address of the first target table entry; An entry in the first branch target buffer whose address is the same as the first target address is determined as the first target entry.

3. The method according to claim 2, characterized in that Mapping the start address of the first branch instruction to the first target address of the first target table entry includes: The first target address is obtained according to the starting address of the first branch instruction and the jump information of the historical branch instructions in the current clock cycle.

4. The method according to claim 1, characterized in that: The method further comprises: In the historical clock cycle, mapping the start address of the second branch instruction to the second target address of the second target table entry; An entry in the second branch target buffer having an address identical to the second target address is determined as the second target entry.

5. The method according to claim 4, characterized in that Mapping the start address of the second branch instruction to the second target address of the second target table entry in the historical clock cycle includes: In the historical clock cycle, the second target address is obtained according to the starting address of the second branch instruction and the jump information of the historical branch instruction in the historical clock cycle.

6. The method according to claim 1, characterized in that The execution result includes a jump address and a jump result, and obtaining the prediction result of the execution of the first branch instruction according to the prediction table entry includes: When the tag information in the prediction table entry is the same as the tag information of the first branch instruction, the jump address and the jump result in the prediction table entry are determined as the prediction result.

7. The method according to claim 6, characterized in that The executing the first branch instruction according to the prediction result includes: When the jump result in the prediction table entry is a jump, performing a read instruction operation from a storage space pointed to by the jump address in the prediction table entry; When the jump result in the prediction table entry is no jump, the next instruction of the first branch instruction is read.

8. The method according to claim 1, characterized in that Before obtaining the prediction result of the execution of the first branch instruction according to the prediction table entry, the method further includes: In the historical clock cycle, according to the starting address of the second branch instruction to be predicted in the history, obtaining the second target table entry in the second branch target buffer; Obtaining a first target table entry in the first branch target buffer according to a start address of the first branch instruction to be predicted in the current clock cycle; According to a preset condition, the predicted table entry is determined from the first target table entry and the second target table entry.

9. The method according to claim 8, characterized in that The determining the predicted entry from the first target entry and the second target entry according to a preset condition includes: When the tag information in the first target table entry is the same as the tag information of the first branch instruction, and the tag information in the second target table entry is the same as the tag information of the first branch instruction, determining the first target table entry as the predicted table entry; When the tag information in the first target table entry is the same as the tag information of the first branch instruction, and the tag information in the second target table entry is different from the tag information of the first branch instruction, determining the first target table entry as the predicted table entry; When the tag information in the first target table entry is different from the tag information of the first branch instruction, and the tag information in the second target table entry is the same as the tag information of the first branch instruction, the second target table entry is determined as the prediction table entry.

10. The method according to claim 8, characterized in that The method further comprises: updating the execution result of the new branch instruction into the table entry corresponding to the branch instruction executed earlier than the new branch instruction in the second branch target buffer; When the table entry corresponding to the branch instruction executed earlier than the new branch instruction is updated to the second branch target buffer by replacing the old table entry in the second branch target buffer, the execution result of the new branch instruction is updated to the table entry corresponding to the new branch instruction in the first branch target buffer.

11. The method according to claim 1, characterized in that: The capacity of the table entries of the first branch target buffer is smaller than the capacity of the table entries of the second branch target buffer.

12. A device for predicting the execution result of a branch instruction, characterized in that: The device comprises: A first determination module is configured to obtain, when a current clock cycle belongs to a first time period, a first target table entry in a preset first branch target buffer according to a start address of a first branch instruction to be predicted in the current clock cycle, and determine the first target table entry as a prediction table entry corresponding to the first branch instruction, and: A second determination module is used to determine, when the current clock cycle belongs to a second time period, a second target table entry obtained from a preset second branch target buffer in a historical clock cycle according to a starting address of a historical second branch instruction to be predicted as a prediction table entry corresponding to the first branch instruction; A prediction module, configured to obtain a prediction result of the execution of the first branch instruction according to the prediction table entry, so as to execute the first branch instruction according to the prediction result; Among them, the first branch target buffer is used to update the execution result of the new branch instruction to the table entry corresponding to the new branch instruction; the second branch target buffer is used to update the execution result of the branch instruction executed later to the table entry corresponding to the branch instruction executed earlier; the first time period is a time period within a preset time length after a flush event occurs in the pipeline of the processor; the second time period is a time period excluding the preset time length after a flush event occurs in the pipeline of the processor.

13. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the method according to any one of claims 1 to 11.

14. A computer-readable storage medium, characterized in that: When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform the method as claimed in any one of claims 1 to 11.