|Publication number||US7984280 B2|
|Application number||US 12/171,370|
|Publication date||Jul 19, 2011|
|Filing date||Jul 11, 2008|
|Priority date||Feb 2, 2005|
|Also published as||US7426631, US8943301, US20060174096, US20080276080, US20110213951|
|Publication number||12171370, 171370, US 7984280 B2, US 7984280B2, US-B2-7984280, US7984280 B2, US7984280B2|
|Inventors||Brian R. Konigsburg, David Stephen Levitan, Wolfram M. Sauer, Samuel Jonathan Thomas|
|Original Assignee||International Business Machines Corporation|
|Export Citation||BiBTeX, EndNote, RefMan|
|Patent Citations (19), Classifications (5), Legal Events (1)|
|External Links: USPTO, USPTO Assignment, Espacenet|
Pursuant to 35 USC §120, this continuation application claims priority to and benefit of U.S. patent application Ser. No. 11/049,014, entitled “METHODS AND SYSTEMS FOR STORING BRANCH INFORMATION IN AN ADDRESS TABLE OF A PROCESSOR”, filed on Feb. 2, 2005, the disclosure of which is incorporated herein in its entirety for all purposes.
The present invention is in the field of processors for computer systems. More particularly, the present invention relates to methods storing branch information in an address table of a processor.
Processors or microprocessors used in processor chips, which are also known as microchips or integrated circuits (ICs), are an integral part of computer systems, performing tasks such as executing and storing instructions. Constantly increasing performance requirements combined with competitive pressures to minimize costs result in significant challenges in processor design. Processor designers attempt, for instance, to extract more and more processing speed from their processor designs. Design changes initiated to increase speed, however, often result in increased area of silicon used by the processor design, resulting in increased costs. Processor design requires such trade-offs between performance and silicon area (and costs).
To improve performance, many processors increase the speed of processing by decoding one or more instructions while the preceding instruction is executing in a process known as pipelining. Many processors also utilize branch processing in their design. Branch processing occurs when a branch instruction implements a jump to another location of instructions, resulting in a break in the flow of instructions performed by the processor. The break in the flow of instructions caused by conditional branch processing results in difficulties in implementing pipelining, as the processor does not know which instruction to next feed into the pipeline. To solve this problem, processor designers use branch prediction where the processor attempts to predict whether the branch instruction will jump or not. The processor will then use the branch prediction to decide which instruction to load next into the pipeline in a process known as speculative execution. If the branch prediction is incorrect, the pipeline is flushed and calculations discarded, but if the branch prediction is correct, the processor has saved a significant amount of time. Static branch prediction utilizes known characteristics of the instruction to provide predictions of which branches are most likely to be taken. Processor designers also may use dynamic branch prediction to further improve performance. Dynamic branch prediction allows the hardware to change its branch predictions as the program executes. The improved performance of dynamic branch prediction becomes particularly useful for processors that attempt to issue more than one instruction per clock cycle.
In order to properly execute branch instructions, information such as the instruction address and predicted target address need be known and stored. One approach to the problem of storing the instruction address and predicted target address is to store the predicted target address along with the instruction text in the instruction buffer (also known as an I-buffer). As processors increase the size of their addressable memory, storing address information in this fashion becomes increasingly wasteful. In a 64-bit machine, for example, each predicted target address will require a full 64-bit register of storage, resulting in an undesirable use of space and silicon. As processors become increasingly sophisticated, the space requirement for the branch prediction information will become even more of an issue.
Dynamic branch prediction requires additional information to be stored, such as an indication of whether a branch was originally predicted to be taken or not taken, exacerbating the problems with using an instruction buffer. To implement dynamic branch prediction, a branch taken indication may be passed along with an instruction, regardless of whether the instruction is a branch instruction or not, potentially resulting in an even larger waste of silicon. Moreover, there is a significant latency associated with fetching instructions, dynamically predicting if branches in the fetch group were taken, and sending this information to the instruction buffer to be dispatched to the branch execution engine. This could result in the branch taken indication not being available to the branch execution mechanism in time for it to be useful.
Another approach to storing address information relating to branch operations is to store the information in a separate branch information queue. A separate branch information queue cuts down on the space requirements of the instruction buffer solution, but it still requires a significant amount of area as well as additional complexity. For processors using dynamic branch prediction and the associated additional storage requirements, the problems associated with using a separate branch information queue are worsened.
There is, therefore, a need for an effective mechanism for storing branch information in a processor that reduces the silicon area used for storage and improves latency. There is an even greater need for such a mechanism as chips become more and more powerful and branch prediction methods such as dynamic branch prediction are used by processor designers.
The problems identified above are in large part addressed by methods and systems for storing branch information in an address table of a processor. One embodiment generally provides a method for storing branch address information in an address table of a computer processor. The method may generally include creating in the address table a first entry, the first entry having a base instruction tag for a first instruction and a base address associated with the first instruction. The method may also generally include, in response to a branch in an entry being predicted taken, creating a new second entry having a second base instruction tag for a second instruction and a second base address associated with the second instruction where an address associated with the instruction tag may be determined based on the base instruction tag and the base address for an entry associated with the instruction tag. The method may further include storing in the address table for each entry one or more of an indication of whether there is a branch present in the entry, an instruction tag of the last branch that is in the entry, and an indication of whether the last branch in the entry is predicted taken. A further embodiment may include provide that the address associated with an instruction tag may be determined by extracting the base instruction tag and the base address for the entry associated with the instruction tag from the address table and calculating the instruction address associated with the instruction tag based on the instruction tag, the base instruction tag, and the base address.
Another embodiment generally provides a method for accessing branch information in an address table of a computer processor. The method may generally include determining an entry of the address table associated with a branch instruction having an instruction tag and determining from the entry whether the branch is present in the entry, whether the last branch of the entry was predicted taken, and whether the instruction tag matches the last instruction tag of the entry. The method also may generally include, in the event that a branch is present in the entry, the last branch of the entry is predicted taken, and the instruction tag matches the last instruction tag of the entry, determining that the branch instruction was predicted to be taken. The method may further include calculating an address associated with a branch instruction based on a base instruction tag and a base address for the entry in the address table associated with the instruction tag. The method may further include determining the predicted target address for the branch instruction by extracting the base address for the entry subsequent to the entry associated with the branch instruction
A further embodiment provides a data processor for processing instructions that includes in one embodiment. The processor may generally include an instruction fetch unit connected to an instruction cache, a branch execution unit, and an address table being connected to the instruction fetch unit and the branch execution unit. The address table may generally be adapted to store a plurality of entries with each entry of the address table being adapted to store a base address and a base instruction tag. In a further embodiment, the branch execution unit may be adapted to determine the address of a branch instruction having an instruction tag based on the base address and the base instruction tag of an entry of the address table associated with the instruction tag. In a further embodiment, the address table may further be adapted to store branch information.
The following is a detailed description of example embodiments of the invention depicted in the accompanying drawings. The example embodiments are in such detail as to clearly communicate the invention. However, the amount of detail offered is not intended to limit the anticipated variations of embodiments; but, on the contrary, the intention is to cover all modifications, equivalents, and alternatives falling within the spirit and scope of the present invention as defined by the appended claims. The detailed descriptions below are designed to make such embodiments obvious to a person of ordinary skill in the art.
Methods and systems for storing branch information in an address table of a processor are disclosed. A processor of the disclosed embodiments may generally include a branch execution unit, an instruction fetch unit connected to an instruction cache, and an address table being connected to the instruction fetch unit and the branch execution unit. The address table may generally be adapted to store a plurality of entries with each entry of the address table being adapted to store a base address and a base instruction tag. In a further embodiment, the branch execution unit may be adapted to determine the address of a branch instruction having an instruction tag based on the base address and the base instruction tag of an entry of the address table associated with the instruction tag. In some embodiments, the address table may further be adapted to store branch information for each entry.
The methods and systems of the disclosed embodiments provide an improved mechanism for storing and accessing branch information in an address table of a processor. By using entries in an address table that may represent multiple instructions, the address table may be made advantageously smaller than previous designs as each instruction address need not be stored in the address table. The address table of the disclosed embodiments may also provide a predicted target address for branch processing systems. The branch execution unit may be connected to the address table. Because a new entry may be created whenever a branch is predicted to be taken, the first address (the base address) of the next entry may provide an indication of the predicted target address of the last branch in the previous entry. The branch execution unit may then extract the predicted target address from the address table, eliminating the need to store such information in an instruction cache or separate branch information queue, saving valuable processor space.
The benefits of the methods and systems of the disclosed embodiments may be amplified when the data processor utilizes dynamic branch prediction with the branch processing routines. Dynamic branch prediction requires additional branch information, such as whether a branch that was taken was actually predicted to be taken. Branch information may also be stored in entries of the address table so that the branch execution unit may determine whether a branch was predicted to be taken. In previous systems, such information typically needed to be passed along with each instruction (whether or not the instruction was a branch instruction), resulting in wasted silicon, or needed to be stored in a separate branch information queue. Moreover, by allowing the branch execution unit to access the address table the latency problem found in previous systems is ameliorated as the branch taken indication can be available immediately instead of waiting for the information from the instruction buffer.
Turning now to the drawings,
In the depicted embodiment, data processor 100 includes a bus interface unit 102 to control the flow of data between data processor 100 and the remainder of a data processing system (not shown). Bus interface unit 102 may be connected to a data cache 104 and an instruction cache 106. Instruction cache 106 may supply an instruction stream to a sequencer unit 108, which forwards individual instructions to the appropriate execution units. An instruction fetch unit 107 may read information from or write information to the instruction cache 106. Execution units may include a load/store unit 110, a branch execution unit 112, one or more fixed point execution units 114, and one or more floating point execution units 116. The fixed point execution units 114 and the load/store unit 110 may read and write their results to a general purpose architectural register file (GPR) 118. The floating point units 116 and the load/store unit 110 may read and write their results to a floating point architectural file (FPR) 120. Data processor 100 may also include a condition register 124, which may store comparison information (such as condition codes) relating to comparisons between different registers. For example, the results of a comparison between two GPR 118 entries may be stored in the condition register 124. The condition register 124 may optionally be connected to the load/store unit 110 so that the load/store unit 110 may also update the condition register 124.
Generally, a branch execution unit 112 may determine what sequence of programmed instructions is appropriate given the contents of certain data registers and the instructions themselves. In one embodiment, branch execution unit 112 may employ one or more dynamic prediction mechanisms to improve performance by predicting the direction of branch instructions early in the pipeline. Instruction fetch unit 107 may provide the sequence of programmed instructions from the branch execution unit 112 to the sequencer unit 108. Instruction fetch unit 107 may fetch instructions from a main memory system external to data processor 100 via bus interface unit 102 if the instructions are not contained within instruction cache 106. The sequencer unit 108 may then dispatch the individual instructions to the various execution units 110, 112, 114, and 116. Each execution unit may perform one or more instructions of a particular class of instructions as indicated by the name of the execution unit. For instance, fixed point execution units 114 may perform mathematical operations on operands expressed in fixed point notation while floating point execution units 116 may perform mathematical operations on operands expressed in floating point notation.
As branch instructions from the branch execution unit 112 progress through the pipeline they will become fully executed (such as by the execution units). The branch execution unit 112 may then determine whether the predicted target address and/or the predicted direction of the branch matches the actual outcome of the branch. In the event that the prediction was incorrect, the branch execution unit 112 may flush undesired instructions and results, redirect the pipeline appropriately, and update the branch prediction information.
To perform its tasks, the branch execution unit 112 may access an address table 122 in order to access branch information. The address table 122, which is described in more detail in relation to
In an alternative embodiment, once all of the instructions in a given entry have completed, the entry of the address table 122 may be invalidated. When an entry is invalidated, the space associated with that entry may be used again, providing additional reductions in the area needed for address table 122, as only entries with instructions currently in the pipeline need be stored.
In a further embodiment, additional branch information may also be stored in the address table 122, such as an indication of whether at least one branch is present in the entry, the instruction tag of the last branch that is in the entry, and an indication of whether the last branch in the entry was predicted taken. Branch execution unit 112 may use this branch information for dynamic branch prediction or any other purpose.
Previous branch execution units 112 accessed branch information via a separate branch information queue or from an instruction cache 106. Using a separate branch information queue required use of silicon of the data processor 100 for the branch information queue, adding expense and using valuable space. Storing branch information with instructions in the instruction buffer of the instruction cache 106 requires each entry in the instruction buffer to include space for branch information, increasing the required size of the instruction cache 106. As more advanced data processors 100 continue to be developed (64 bit processors, for example), the wasted space in the instruction cache 106 becomes even more pronounced, as the branch address, for example, will require 64 additional bits for each instruction in a 64 bit processor. In contrast, the information storage system of the disclosed embodiments takes advantage of the storage already required as part of the address table 122 by connecting the branch execution unit 112 to the address table 122.
The methods of the disclosed embodiments may also provide an improved address table 122 when compared to previous methods. In the disclosed embodiment, the address of each instruction need not be stored. Instead, a base instruction tag and a base address allow a base address to be stored for each entry, where each entry may have a plurality of associated instructions. The disclosed address table 122 only requires the address to be stored for the first instruction of each entry, reducing the required size of the address table 122 and saving valuable space and silicon on the data processor 100.
If no branch in the current entry is predicted to be taken, flow chart 200 continues to optional decision block 206, determining whether a cache line crossing relating to a new fetch group has occurred with the new instruction received at element 202. If there has been a cache line crossing relating to a new fetch group, flow chart 200 continues to element 208, creating a new entry in the address table 122. In this optional embodiment, a new entry is required whenever there is a cache line crossing relating to a new fetch group so that instructions in one address table 122 entry only pertain to one fetch group. After creating a new entry (or if optional decision block 206 is not used), flow chart 200 continues to element 210, inserting the instruction and any branch information into the address table 122.
Whether a new entry is created at element 208 or not (based on an affirmative response in either decision block 204 or 206), the instruction and any branch information may be inserted into the address table 122 at element 210, after which the flow chart terminates. If no new entry is created, the address of the instruction need not be inserted into the address table 122 as its address may be determined using the method described in relation to
Once a request for an instruction address is received, flow chart 300 continues to element 304, extracting the base instruction tag and base address from the address table 122. In one embodiment, the base instruction tag and the base address should be the ones from the entry to which the unknown instruction address relates. Next, at element 306, flow chart 300 may calculate the instruction address associated with the instruction tag. In one embodiment, the instruction address may be calculated using the following equation:
<instruction address>=<table base address>+(<instruction tag>−<base instruction tag>)*IL
where IL represents a fixed instruction length. In one example, if an instruction has an instruction tag of ‘7’, the base address is ‘0x000—0000—0000—0040’, the base instruction tag of the entry is ‘2’, and the fixed instruction length is ‘4’ (representing a 4 byte instruction address), the instruction address may be calculated as follows:
The space savings resulting from the disclosed embodiments may clearly be seen as the addresses for the instructions with instruction tags of 3, 4, 5, 6, and 7 need not be stored in the address table and only the base address must be stored. Using the methodology of elements 304 and 306, the instruction address for an instruction not stored in the address table 112 may straightforwardly be determined.
After calculating the instruction address at element 306, flow chart 300 may continue to optional element 308 to determine the predicted target address of a branch in the entry. At element 308, the predicted target address may be equated to the base address of the next entry. As a new entry is created when a branch is predicted taken (as described in relation to
If there is an indication that a branch is present in the entry, flow chart 400 continues to decision block 406. At decision block 406, the branch execution unit 112 may determine whether the branch instruction tag matches the instruction tag of the last branch of the entry. If the branch instruction tag does not match the instruction tag of the last branch of the entry, flow chart 400 continues to element 412 where it determines that the branch was not predicted to be taken, after which the flow chart terminates. If the branch instruction tag does not match the tag of the last branch indicated in the address table 122, the branch cannot have been predicted to be taken since a prediction of a branch being taken results in the creation of a new entry (and closing of the current entry to new instructions). Since the tags do not match, it implies that there are more instructions associated with the entry and the branch cannot have been predicted taken.
After determining that the branch instruction tag is the last branch of the entry, flow chart 400 continues to decision block 408, where it determines whether the last branch predicted taken indicator is affirmative. If there is an indication that the last branch predicted in the entry was taken, flow chart 400 continues to element 410 where it is determined that the instruction branch received at element 402 was the branch predicted to be taken. After element 410, flow chart 400 terminates. If the last prediction taken indication is negative, flow chart 400 continues to element 412 where it determines that the branch was not predicted to be taken, after which the flow chart terminates. If the last branch predicted taken is negative, the branch cannot have been predicted to be taken since it was determined to be the last branch in the entry.
In one example, if instruction tag ‘0x4’ was sent to the branch execution unit 112, the branch execution unit 112 may use table 600 stored in address table 122 to determine whether the instruction tag was predicted taken. The entry related to instruction tag ‘0x4’ would be the entry with base instruction tag ‘0x2’, as instruction tag ‘0x4’ is in between base instruction tags ‘0x2’ and ‘0x5’, indicating that it is related to the first entry of that pair. Analyzing the entry, both the branch in entry column 604 and the last branch taken column 608 have affirmative indications and the instruction tag matches the tag of the last branch column 606 (‘0x4’), so the branch execution unit may then determine that the instruction associated with instruction tag ‘0x4’ was a branch instruction that was predicted taken.
Conversely, if the instruction tag ‘0x10’ is sent to the branch execution unit 112, the branch execution unit 112 would determine that it relates to the entry starting with base instruction tag ‘0x5’ and that the branch was not predicted taken, as the last branch taken indication 608 of its associated entry is negative. Similarly, the instruction tag ‘0x17’ would be determined to have been predicted not taken as its branch in entry column 604 indicates negative. An entry with no branches, such as the entry with base instruction tag ‘0x13’, may have null values in columns 606 and 608.
In general, the routines executed to implement the embodiments of the invention, may be part of an operating system or a specific application, component, program, module, object, or sequence of instructions. The computer program of the present invention typically is comprised of a multitude of instructions that will be translated by the native computer into a machine-readable format and hence executable instructions. Also, programs are comprised of variables and data structures that either reside locally to the program or are found in memory or on storage devices. In addition, various programs described hereinafter may be identified based upon the application for which they are implemented in a specific embodiment of the invention. However, it should be appreciated that any particular program nomenclature that follows is used merely for convenience, and thus the invention should not be limited to use solely in any specific application identified and/or implied by such nomenclature.
It will be apparent to those skilled in the art having the benefit of this disclosure that the present invention contemplates a method and system for storing branch information in an address table of a processor. It is understood that the forms of the invention shown and described in the detailed description and the drawings are to be taken merely as examples. It is intended that the following claims be interpreted broadly to embrace all the variations of the example embodiments disclosed.
|Cited Patent||Filing date||Publication date||Applicant||Title|
|US5222224||Jul 9, 1991||Jun 22, 1993||Digital Equipment Corporation||Scheme for insuring data consistency between a plurality of cache memories and the main memory in a multi-processor system|
|US5414822 *||Apr 3, 1992||May 9, 1995||Kabushiki Kaisha Toshiba||Method and apparatus for branch prediction using branch prediction table with improved branch prediction effectiveness|
|US5471597||Dec 8, 1994||Nov 28, 1995||Unisys Corporation||System and method for executing branch instructions wherein branch target addresses are dynamically selectable under programmer control from writable branch address tables|
|US5509137 *||Mar 16, 1994||Apr 16, 1996||Mitsubishi Denki Kabushiki Kaisha||Store processing method in a pipelined cache memory|
|US5530825 *||Apr 15, 1994||Jun 25, 1996||Motorola, Inc.||Data processor with branch target address cache and method of operation|
|US5574871||Jan 4, 1994||Nov 12, 1996||Intel Corporation||Method and apparatus for implementing a set-associative branch target buffer|
|US5577217 *||May 7, 1996||Nov 19, 1996||Intel Corporation||Method and apparatus for a branch target buffer with shared branch pattern tables for associated branch predictions|
|US5584001 *||Jul 31, 1995||Dec 10, 1996||Intel Corporation||Branch target buffer for dynamically predicting branch instruction outcomes using a predicted branch history|
|US5737590 *||Dec 27, 1995||Apr 7, 1998||Mitsubishi Denki Kabushiki Kaisha||Branch prediction system using limited branch target buffer updates|
|US5740415 *||Oct 3, 1995||Apr 14, 1998||Mitsubishi Denki Kabushiki Kaisha||Instruction supplying apparatus with a branch target buffer having the contents so updated as to enhance branch prediction accuracy|
|US5822577 *||May 1, 1996||Oct 13, 1998||International Business Machines Corporation||Context oriented branch history table|
|US5835754 *||Mar 13, 1997||Nov 10, 1998||Mitsubishi Denki Kabushiki Kaisha||Branch prediction system for superscalar processor|
|US5842008 *||Jun 18, 1996||Nov 24, 1998||Intel Corporation||Method and apparatus for implementing a branch target buffer cache with multiple BTB banks|
|US5860017||Jun 28, 1996||Jan 12, 1999||Intel Corporation||Processor and method for speculatively executing instructions from multiple instruction streams indicated by a branch instruction|
|US5953512||Dec 29, 1997||Sep 14, 1999||Texas Instruments Incorporated||Microprocessor circuits, systems, and methods implementing a loop and/or stride predicting load target buffer|
|US6021489||Jun 30, 1997||Feb 1, 2000||Intel Corporation||Apparatus and method for sharing a branch prediction unit in a microprocessor implementing a two instruction set architecture|
|US6108773||Mar 31, 1998||Aug 22, 2000||Ip-First, Llc||Apparatus and method for branch target address calculation during instruction decode|
|US6484256 *||Aug 9, 1999||Nov 19, 2002||International Business Machines Corporation||Apparatus and method of branch prediction utilizing a comparison of a branch history table to an aliasing table|
|US7069426||Mar 28, 2000||Jun 27, 2006||Intel Corporation||Branch predictor with saturating counter and local branch history table with algorithm for updating replacement and history fields of matching table entries|
|U.S. Classification||712/239, 712/240|