Device and method for processing instructions
By introducing prediction circuits and optimization circuits into the data processing system, and using prediction source operation values to optimize instruction execution, the problem of low performance caused by waiting for source operation values is solved, and more efficient resource utilization and power consumption savings are achieved.
Patent Information
- Application Number
- CN201980056175.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Priority Date
- 2018-09-26
- Filing Date
- 2019-07-17
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2039-07-17
AI Technical Summary
When executing instructions, existing data processing systems need to wait for the source operation value to be available, resulting in low performance. When using a value prediction system, although performance can be improved, there is still room for optimization.
A device and method are provided, including an execution circuit, an issue circuit, a prediction circuit and an optimization circuit, which optimize instruction execution by predicting source operation values, avoid executing pending instructions when detecting optimization conditions, release resources and save power consumption.
Significantly improve performance and power consumption efficiency, predict the result value by predicting the source operation value, avoid unnecessary instruction execution, and improve the overall performance and resource utilization of the system.
Smart Images

Figure CN112639729B_ABST
Abstract
Description
Technical Field
[0001] The present technology relates to a device and method for processing instructions. Background Art
[0002] The data processing device will usually provide an execution circuit for executing a sequence of instructions, wherein each instruction may need to use one or more source operand values to perform an associated operation to produce a result value. Before the execution circuit can execute a specific instruction, the source operand value of the instruction must be available. For example, the situation may be that one or more source operand values required for a specific instruction are generated as the result value of other earlier instructions. In such a situation, before the above-mentioned specific instruction is considered to make its source operand value available and therefore can be dispatched to the execution circuit, it is usually necessary to wait for any such result value to be generated.
[0003] In order to seek to improve performance, some systems provide value prediction circuitry for generating predicted source operand values for one or more instructions. Based on such predicted source operand values, instructions can then be issued to execution circuitry (as long as any other required source operand values are also available), which can improve performance if the predicted source operand values are correct. When appropriate, a determination can be made as to whether the predicted source operand values are correct, and if not, the state of the processing system can be returned to a point before the predicted source operand values were utilized, while re-executing any affected instructions taking into account the actual source operand values.
[0004] It would be desirable to further improve the performance benefits obtainable in systems employing value prediction. Summary of the invention
[0005] In one example arrangement, a device is provided, comprising: execution circuitry for executing instructions, each instruction requiring the use of one or more source operand values to perform an associated operation to produce a result value; issue circuitry for maintaining a record of pending instructions awaiting execution by the execution circuitry; prediction circuitry for generating predicted source operand values for selected pending instructions; and optimization circuitry for detecting an optimization condition for the selected pending instruction when: given the associated operation of the selected pending instruction, the predicted source operand values cause the result value to be known without performing the associated operation; wherein the optimization circuitry is arranged to: in response to detecting the optimization condition, implement the optimization operation rather than causing the execution circuitry to perform the associated operation to execute the selected pending instruction.
[0006] In another example arrangement, a method for processing instructions is provided, the method comprising: providing execution circuitry to execute the instructions, each instruction requiring the use of one or more source operand values to perform associated operations to produce a result value; maintaining a record of pending instructions waiting to be executed by the execution circuitry; employing prediction circuitry to generate predicted source operand values for selected pending instructions; detecting an optimization condition for the selected pending instruction when: given the associated operations of the selected pending instruction, the predicted source operand values make the result value known without performing the associated operations; and in response to detecting the optimization condition, implementing the optimization operation rather than causing the execution circuitry to perform the associated operations to execute the selected pending instruction.
[0007] In yet another example arrangement, a device is provided, comprising: an execution device for executing instructions, each instruction requiring the use of one or more source operand values to perform an associated operation to produce a result value; an issuance device for maintaining a record of pending instructions waiting to be executed by the execution device; a prediction device for generating predicted source operand values for selected pending instructions; and an optimization device for detecting an optimization condition for the selected pending instruction when: given the associated operation of the selected pending instruction, the predicted source operand value makes the result value known even without performing the associated operation; wherein the optimization device is arranged to: in response to detecting the optimization condition, implement the optimization operation rather than causing the execution device to perform the associated operation to execute the selected pending instruction. BRIEF DESCRIPTION OF THE DRAWINGS
[0008] The present technology will be further described, by way of illustration only, with reference to examples of the present technology as shown in the accompanying drawings, in which:
[0009] Figure 1 is a block diagram of a data processing device according to an example configuration;
[0010] Figure 2 Schematically illustrates that in one example arrangement, Figure 1 Information maintained in forecast tables;
[0011] Figure 3 is shown in an example arrangement Figure 1 Flowchart of the operation of the optimization analyzer.
[0012] Figure 4 is an illustration of an example arrangement that may be performed to implement Figure 3 A flowchart of the steps of the optimization operation of step 165;
[0013] Figure 5AIllustration of how an ordered data processing arrangement can be implemented in an example arrangement Figure 4 Step 210;
[0014] Figure 5B Illustration of how out-of-order data processing can be implemented in an example arrangement Figure 4 Step 210;
[0015] Figure 6 is an illustration of what can be done in one example arrangement to achieve Figure 3 A flowchart of an optional sequence of steps for optimizing the operation of step 165;
[0016] Figure 7 is shown in an example arrangement except Figure 3 A flowchart of further optimizations that can be achieved beyond the final step of
[0017] FIG. 8A to FIG. 8D illustrates various example scenarios in which the optimization techniques described herein may be utilized; and
[0018] Fig. 9 A vector processing implementation is illustrated in which the optimization techniques described herein may be applied independently within different channels of parallel processing. DETAILED DESCRIPTION
[0019] In one example arrangement, a device is provided having execution circuitry for executing instructions, wherein each instruction requires the use of one or more source operand values to perform an associated operation to produce a result value. Issue circuitry is used to maintain a record of pending instructions waiting to be executed by the execution circuitry. Additionally, prediction circuitry is provided to generate predicted source operand values for selected pending instructions. As previously described, by providing predicted source operand values, the selected pending instructions can be available for execution more quickly than if they had to wait for the availability of actual source operand values.
[0020] However, according to the technology described herein, in some cases, further performance and / or power consumption benefits can be achieved according to the form of the predicted source operand value and the associated operation that needs to be performed on the selected pending instruction. In particular, the device has an optimization circuit, which is arranged to detect an optimization condition for the selected pending instruction in the following situation, taking into account the associated operation of the selected pending instruction, the predicted source operand value makes the result value known without performing the associated operation. The optimization circuit is arranged to: in response to detecting the optimization condition, implement the optimization operation instead of causing the execution circuit to perform the associated operation to execute the selected pending instruction. Therefore, in the case of detecting the optimization condition, it can be determined that the selected pending instruction does not need to be executed to produce the result value for the selected pending instruction, which can produce significant performance and / or power consumption benefits. In particular, since the selected pending instruction does not need to be executed, this frees up resources within the execution circuit to execute other instructions, thereby improving performance. In addition, since the result value is determined without executing the selected pending instruction in the execution circuit, this can save power consumption.
[0021] Then, additional benefits can also be achieved for any dependent instructions in the issue queue. In particular, the optimization circuit can be arranged to identify the dependent instructions in the issue queue that use the result value of the selected pending instruction as a source operand. Because the result value is known when the associated operation is not performed in the presence of an optimization condition, the related source operands of the dependent instructions can also be identified as known, i.e., known result values, so that the issue circuit will then consider that the source operands can be used for the dependent instructions. This can allow the dependent instructions to be dispatched to the execution circuit to be executed earlier than when the device must wait for the execution of the selected pending instruction to produce the result value.
[0022] Therefore, it will be seen that the above-mentioned technology enables the result value of the selected pending instruction to be determined based on the speculation made by the source operand using the prediction, and can allow this result value to be used as the source operand relevant to any related instruction in the issue queue in addition.This enables the speculation of the enhanced level to be performed based on the source operand value of the prediction, which can cause the performance improved significantly under the correct situation of the source operand value of the prediction.As previously discussed, under the incorrect situation of the source operand value of the prediction when determining in due time, the state of the processing device can be rewound to the appropriate point in the instruction stream using the standard replay mechanism, and then the affected instruction is re-executed using the actual source operand value.
[0023] In one example arrangement, the selected pending instruction provides a destination register identifier, and the optimization operation includes submitting a known result value to a register determined from the destination register identifier once the predicted source operand value is determined to be correct. Thus, while the above techniques may be used to achieve an enhanced level of speculation in the presence of optimization conditions, the result value is not actually submitted (i.e., the architectural state of the system is not updated) until the predicted source operand value is determined to be correct. However, at this time, a known result value determined taking into account the predicted source operand value and associated operation of the selected pending instruction may be submitted without executing the selected pending instruction to determine the result value.
[0024] There are many ways in which the predicted source operand value can be determined to be correct. In an example arrangement, each instruction is arranged to identify one or more source operand values by providing an associated source register identifier, and the selected pending instruction provides a source register identifier for the source operand value predicted by the prediction circuit, and the source register identifier is the destination register identifier of the earlier instruction in the instruction sequence to be executed by the execution circuit. In such a situation, once the result value is determined for the earlier instruction and it is determined that it matches the predicted source operand, the predicted source operand value of the selected pending instruction can be determined to be correct. Therefore, a standard speculation checking mechanism can be used to determine whether the predicted source operand value is correct. In the case where the predicted source operand value is determined to be correct, then the performance benefits obtained according to the enhanced speculation discussed previously can be realized (wherein not only based on the predicted source operand value, but also based on the optimization circuit determining that the result value is known to perform speculation when the selected pending instruction is not executed).
[0025] The above optimization techniques can be employed in a wide variety of different systems. For example, the techniques can be applied in an in-order processor arrangement where instructions are executed in the original program order or in an out-of-order processor arrangement where instructions are allowed to be executed out-of-order relative to the original program order.
[0026] Within the in-order arrangement, the optimization circuitry may be arranged to implement the optimization operation by causing the execution circuitry to write the known result value to a register determined from the destination register identifier. As previously discussed, this occurs once the predicted source operand value is determined to be correct, so it is safe to update the architectural state of the system by writing the known result value to the relevant register.
[0027] In an out-of-order arrangement, it may not be necessary to write a known result value to a register at a commit point. In particular, where the device supports speculative execution of instructions by execution circuitry out of order relative to the original program order of the instructions, the device may also include a register renaming circuit to map an architectural register identified by a register identifier in the instruction to a physical register within a physical register set, wherein the number of physical registers exceeds the number of architectural registers. As will be appreciated by those of ordinary skill in the art, register renaming is a technique that can eliminate false data dependencies that arise from the reuse of architectural registers by consecutive instructions that do not have any true data dependencies between them. The elimination of such false data dependencies can reveal more instruction-level parallelism in the instruction stream, which can then be exploited to improve performance. By using a larger physical register set and register renaming techniques, multiple versions of the same architectural register can exist simultaneously.
[0028] In such a system, rather than writing to registers at commit points, the optimization circuitry may be arranged to implement the optimization operation by causing the register renaming circuitry to perform a remapping such that the architectural register identified by the destination register identifier is mapped to a physical register containing a known result value.
[0029] Although such remapping can only be committed when the predicted source operand value is determined to be correct, in one example arrangement, the optimization circuitry may be arranged to speculatively perform the remapping before the predicted source operand value is determined to be correct, and then commit the remapping when the predicted source operand value is determined to be correct. A number of techniques may be used to distinguish between speculative remappings and committed remappings. For example, different remapping tables may be used for speculative remappings and committed remappings, or alternatively, an additional field may be provided in association with each remapping to identify whether it is a speculative remapping or a committed remapping. By performing remappings speculatively, this further increases the performance benefits that can be achieved, for example by enabling related instructions to be executed using speculative remappings.
[0030] Thus, in one example arrangement, remapping may be used to trigger further optimization operations for at least one dependent instruction that uses a result value of the selected pending instruction as a source operand.
[0031] The dependent instructions that may be subject to further optimization operations may take various forms. However, as a specific example, at least one dependent instruction may be a move instruction that identifies a result value of a selected pending instruction as a source operand, and the further optimization operation causes the register renaming circuitry to perform further remapping such that the architectural register identified by the destination register identifier of the move instruction is also mapped to a physical register containing a known result value.
[0032] Therefore, it should be understood that in such a situation, not only does it not need to execute the selected pending instruction, but it also does not need to execute the dependent instructions, because in both cases, as long as the predicted source operand values are correct, the result of the instruction is known. This can significantly improve performance when executing the instruction stream.
[0033] There are various situations in which the optimization circuitry can detect the presence of an optimization condition based on the predicted source operand values and the associated operation of the selected pending instruction. In one example arrangement, the associated operation of the selected pending instruction operates on multiple source operand values, and the associated operation is such that when the predicted source operand value is a predetermined value, the known result value is given by one of the source operand values. Therefore, in such an arrangement, the known result value can be derived directly from one of the source operand values.
[0034] The predetermined value of the predicted source operand may vary depending on implementation, but in one example arrangement, the predetermined value is 0. Therefore, in such a situation, when the predicted source operand value is 0, the optimization circuitry may be arranged to determine, based on an associated operation of the selected pending instruction, whether a result value is known without performing the associated operation.
[0035] There are various different forms of instructions that may be such. For example, the selected pending instruction may be a multiplication instruction, in which case, when the predicted source operand value is 0, the result value is known to be 0. In particular, once it is known that one of the source operands of the multiplication instruction is 0, the result value will be 0, regardless of the value of the other source operand.
[0036] As another example, the selected pending instruction can be a multiplication-accumulation instruction, requiring the first source operand and the second source operand to be multiplied together to form an intermediate result, which is then added to the accumulation source operand. When the predicted source operand value is zero for a source operand in the first source operand and the second source operand, the known result value will be provided by the accumulation source operand. Therefore, in such a situation, it is known that when performing a multiplication-accumulation operation, the accumulation source operand will not change, so the known result value can be directly provided by the accumulation source operand.
[0037] In an implementation where the destination register identifier is specified separately from the source register identifier of the accumulated source operand, the architectural state associated with the register determined according to the destination register identifier can be updated (by writing to the destination register or by remapping within the register renaming circuit), and once the predicted source operand value is known to be correct, the contents of the register are identified as the accumulated source operand value. However, in some implementations, the destination register identifier is also the source operand identifier of the accumulated source operand. This form of encoding is commonly used because it provides efficient encoding for multiply-accumulate instructions. In such cases, submitting a known result value to a register determined according to the destination register identifier simply includes keeping the contents of the register unchanged. Therefore, at the commit point, there is no need to write to the destination register or update the register renaming table.
[0038] As another example, the selected pending instruction can be an addition or subtraction instruction that operates on a first operand and a second operand, and for one of the first operand and the second operand, the predicted source operand value can be 0. In this case, the known result value is determined based on the value of the other of the first operand and the second operand. For the addition instruction, the known result value will be directly given by the value of the other of the first operand and the second operand, just as the addition operation AB case in which operand B is predicted to be 0. In addition, in the case of a subtraction instruction in which operand A is predicted to be 0, it should be understood that the result value "-B" can still be effectively determined based on the other operand B without performing a subtraction operation, for example, it may only involve flipping the sign bit.
[0039] Although in the above example, the optimization circuitry looks for the presence of an optimization condition when the predicted source operand value is 0, the technique may also be used when the predicted source operand value has a different value. For example, the predicted source operand value may be 1.
[0040] In one such example, the selected pending instruction may be a multiplication instruction that operates on a first operand and a second operand. In the case where the predicted source operand value for one of the first operand and the second operand is 1, the known result value is given by the value of the other of the first operand and the second operand.
[0041] The above techniques may be used in scalar processing circuitry or in vector processing circuitry. For example, the execution circuitry may be arranged to perform vector processing operations in a plurality of parallel processing lanes, and the optimization circuitry may be arranged to evaluate for each lane whether an optimization condition exists, such that the optimization operation can be applied to any lane for which the source operand values predicted for the lane make the result value of the lane known even without performing the associated operations, taking into account the associated operations of the selected pending instructions. This provides a flexible and efficient mechanism for achieving the previously described performance and / or power benefits when an optimization condition is detected in one or more lanes of parallel processing within the execution circuitry.
[0042] Specific examples will now be described with reference to the figures.
[0043] Figure 1 1 is a block diagram illustrating a data processing device according to an example implementation. The fetch stage 10 is used to fetch instructions identified by fetch addresses from the instruction cache 15. The fetch stage may be coupled to a branch prediction circuit for predicting the outcome of a branch instruction and generating a series of fetch addresses of instructions to be fetched by the fetch stage 10 based on the prediction.
[0044] The decode stage 20 decodes the fetched instructions to generate control information for controlling subsequent stages of the pipeline. The control information thus generated may also be referred to herein as decoded instructions.
[0045] In an in-order processing system, the decoded instructions generated by the decode stage 20 may be routed directly to the issue stage 30, which provides an issue queue 35 in which the decoded instructions are stored, but which are pending instructions awaiting execution by the execution stage 45. However, in an out-of-order system, a register renaming stage 25 may additionally be provided for performing register renaming to remap architectural register designators identified by the instructions to physical register designators identifying registers within the register file 50 provided in hardware. Register renaming may be used to support out-of-order execution, as this may allow the elimination of hazards between instructions that specify the same architectural register by mapping the instructions to different physical registers in the hardware register file to increase the likelihood that the instructions may be executed in an order different from the program order in which the instructions were fetched from the instruction cache 15, which may improve performance by allowing later instructions to be executed while earlier instructions are waiting for operands to become available. The ability to map architectural registers to different physical registers may also facilitate rollback of architectural state in the event of a branch misprediction.
[0046] After register renaming, the decoded instruction information may be stored in issue queue 35 of issue stage 30 or, as previously discussed, in the case of an in-order system that does not use register renaming, the decoded instruction information from decode stage 20 may be provided directly to issue stage 30 for storage in issue queue 35.
[0047] The issue stage 30 queues instructions waiting to be executed until the source operands required to process those instructions are available. For example, the source operands of a particular instruction may be generated as a result value from executing an earlier instruction in the execution stage, and once the result value becomes available from the execution stage, either by being written into the appropriate register in the register file 50 or forwarded on the forwarding path, the particular instruction may be issued from the issue queue as long as any other source operands are also available. The execution stage 45 executes the instructions to perform the corresponding processing operations, and the results may then be output from the execution stage for writing into the register file 50.
[0048] The execution stage may include many execution units, such as a branch unit for evaluating whether a branch instruction has been correctly predicted, an ALU (arithmetic logic unit) for performing arithmetic logic operations, a floating point unit for performing operations using floating point operands, and a load / store unit for performing a load operation to load data from a memory system to a register of the register group 50 or a store operation to store data from a register of the register group 50 to the memory system.
[0049] In the example shown, the memory system includes a level 1 instruction cache 15, a level 1 data cache 55, and one or more additional cache levels between the level 1 instruction cache and the level 1 data cache and the main memory. Figure 1 These additional cache levels and main memory are omitted.
[0050] Once the source operands of the pending instructions are available, the pending instructions in the issue queue 35 may be issued to the execution stage 45. In order to allow for potential earlier execution of instructions, a value prediction circuit 60 may be provided which maintains a prediction table 65 which seeks to maintain prediction values for one or more architectural registers which may be specified by the instruction. There are various ways in which the prediction table may be organized and maintained, the purpose of which is to seek to provide prediction values for architectural registers at a desired confidence level.
[0051] Figure 2An example arrangement of a prediction table 65 is illustrated, the prediction table comprising a plurality of entries 100, one entry for each architectural register that may be specified by an instruction. In an in-order (INO) system, these architectural registers will also correspond directly to individual physical registers within the register file 50. However, in an out-of-order (OOO) system, a larger number of physical registers will be present within the register file 50, and the register renaming stage 25 is used to maintain a mapping between the architectural registers and the physical registers of the register file 50. In either implementation, the prediction table may be used to seek to predict the value of a particular architectural register. In an example arrangement, this may be achieved by seeking to maintain, for each architectural register, a history of values observed via results provided from the execution stage.
[0052] exist Figure 2 In the example of , each entry 100 contains four fields. A first field 105 is used to identify the architectural register, while a second field 110 is used to maintain a history of result values produced by the execution stage for that architectural register. A predicted value field 115 is then used to maintain a predicted value for that architectural register, which may be determined based on an analysis of the history of the values in field 110. Finally, a confidence field 120 is used to provide a confidence value indicating a confidence level for the predicted value within the predicted value field 115. In one example implementation, the value prediction circuitry 60 will only begin using the predicted value of the architectural register to make predictions once the associated confidence value has reached a predetermined threshold indicating an associated accuracy in the predicted value.
[0053] Considering entry 100 maintained for architectural register R0 as an example, then Figure 2 As shown, the history of values can indicate the value V a 、V b 、V c etc., wherein the value prediction circuit seeks to predict any pattern in the history of the observed values, and provides a predicted value based thereon. A confidence indication may also be maintained to indicate a confidence level in the predicted value. For example, if a regular pattern is observed in the history of the value, an extension of the regular pattern may be used to generate a predicted value. When the next result is determined for the architectural register, if the result matches the predicted value, the confidence value may be adjusted to indicate an increased confidence in the prediction. At the same time, the predicted value may be updated based on the pattern. This process may continue until the confidence level indicated by the confidence value has reached a selected threshold level, after which the value prediction circuit may output the current predicted value of the register to the release stage 30 for subsequent occurrences where register R0 is used as a source operand.
[0054] For an ordered system, the output from the value prediction circuitry may simply identify the architectural register and the predicted value of the architectural register. However, for an out-of-order system, the output from the value prediction circuitry will also use information obtained from the register renaming stage to be able to identify the physical register that provides the predicted source operand value. The issue queue will maintain a list of pending instructions and an indication of the source operand identifiers for the source operands required for each of these instructions. For an ordered system, those source operand identifiers may identify the architectural register that will provide the source operand value, however for an out-of-order system, those source operand identifiers may identify the physical register for each source operand as provided by the output from the register renaming stage 25.
[0055] When the predicted source operand value is provided from the value prediction circuit, the issue stage 30 can then update the information maintained in the issue queue so that any instruction waiting for the source operand value can be marked as making the source operand available. In particular, the predicted source operand value can be used as the source operand value at this time without waiting for the actual source operand value to become available. This can allow instructions to be available for issuance from the issue stage 30 to the execution stage 45 earlier than otherwise possible, thereby achieving improved performance.
[0056] In addition, according to the techniques described herein, when the predicted source operand value takes a specific value, the release stage may employ an optimization analyzer 40 to seek to determine whether an optimization condition exists for the instruction that will use the predicted source operand value. In particular, the optimization analyzer 40 (which may also be referred to herein as an optimization circuit) is arranged to detect the optimization condition for a particular pending instruction when the predicted source operand value used by the instruction makes the result value known without performing the associated operation, taking into account the associated operation of the particular pending instruction. In the event that the optimization condition is detected, the release stage 30 may be arranged so that, when it is determined that the particular pending instruction is to be executed, the instruction is not actually executed by the execution stage 45, but instead, the known result value is directly used without executing the instruction to perform the associated operation.
[0057] Thus, performance is improved by avoiding the need to execute instructions when an optimization condition is detected, thereby freeing up resources of the execution stage 45 for performing other operations. In addition, power consumption benefits may be achieved by avoiding the need to employ an execution stage to execute this particular instruction.
[0058] Therefore described technology makes it possible to realize the speculation of enhanced level based on the source operand value of prediction.Especially, not only the source operand value of prediction is provided before actual source operand is produced, the source operand value of prediction itself is used as the mechanism of speculation, and when there is optimization condition, the result value of some instructions can be directly determined according to the source operand of prediction, without actually performing these instructions.In some cases, those result values itself can be used to further improve the level of performed speculation then, for example, by identifying any relevant instruction of using such result value as source operand in the issue queue, and also those instructions are marked as making this source operand available.This can provide obvious benefit under the correct situation of the source operand value of prediction.As discussed previously, because once the value prediction circuit has the confidence level needed in prediction, just make prediction, so the accuracy of the source operand value of prediction then can reach the level that has realized remarkable performance benefit by using above-mentioned optimization technology.
[0059] In the event that speculation on predicted source operand values proves to be incorrect, a rollback mechanism may be implemented to return the state of the processing pipeline to a point before the predicted source operand values were used, and then replay the affected instructions using the actual source operand values.
[0060] When an actual result value is produced from the execute stage 45, the contents of the prediction table 65 may then be updated. In an in-order system, the result information will identify the architectural register and the result, allowing the prediction table to be updated directly. For an out-of-order system, the execute stage may identify the physical register and the result, and then, with reference to the remapping performed by the register renaming circuit 25, the relevant architectural register may be identified within the prediction table, and the contents of that entry updated.
[0061] When the optimization analyzer determines that an optimization condition exists for a selected pending instruction in the issue queue 35, then the optimization operation performed may include submitting a known result value to a register determined according to a destination register identifier specified by the selected pending instruction once the predicted source operand value is determined to be correct. In particular, as with any form of speculation, the device will be arranged to only submit updates to the architectural state once the associated speculation has been found to be correct. Therefore, although the known result value may be determined immediately based on the predicted source operand value, it is appropriate not to submit the result value to the architectural state of the system until the predetermined source operand value is determined to be correct.
[0062] For an ordered system, once a commit point is reached, the optimization operation may cause the execution circuit to write the known result value to the register determined by the destination register identifier without requiring the execution circuit to execute the instruction. For an out-of-order system, it may not be necessary to perform any updates to the register set at this commit stage, but instead, the register renaming circuit within the register renaming stage 25 may be arranged to perform a remapping so that the architectural register identified by the destination register identifier of the selected pending instruction is mapped to the physical register containing the known result value. Therefore, although the architectural register identified by the destination register identifier of the selected pending instruction may initially be mapped to any arbitrary available physical register, once an optimization condition is detected, the register may be remapped so that the architectural register is instead mapped to the physical register containing the known result value.
[0063] Although the remapping may only be committed once the predicted source operand values are known to be correct, the optimizing analyzer 40 may be arranged to cause the register renaming stage to perform remapping speculatively before the predicted source operand values are determined to be correct, and then commit the remapping when the predicted source operand values are determined to be correct. The register renaming stage may maintain information about the speculative or committed nature of any mapping in various ways. For example, it may maintain separate tables for any speculative mappings and committed mappings, or alternatively, additional fields may be provided for each entry in the mapping table to identify whether the mapping is a speculative mapping or a committed mapping.
[0064] Figure 3 1 is a flow chart illustrating the operation of the optimization analyzer 40 in one example arrangement. At step 150, it is determined whether a predicted source operand value for a particular pending instruction has been received from the value predictor 60. If so, then at step 155, it is determined whether the predicted value is such that the result of the operation identified by the pending instruction is known without executing the instruction. There are many situations in which this can be determined. For example, if the predicted value is 0 and the operation is a multiplication operation of multiplying the source operand predicted to be 0 by another source operand, then it will be known that the result value is zero assuming that the predicted value proves to be correct.
[0065] If it is determined at step 155 that the result value is unknown based on the prediction value and the type of operation to be performed, then the process proceeds to step 160 where the instruction is processed normally. In particular, the instruction may be issued to execution stage 45 earlier than would be possible due to providing a predicted source operand value, but no assumption is made about the result value, and instead the instruction is executed by execution stage 45 at that point to produce the result value.
[0066] However, if it is determined at step 155 that the result value is known without executing the instruction based on the predicted source operand values and the required operation, then at step 165 an optimization operation is implemented rather than having the execute stage execute the instruction.
[0067] Figure 4 is a diagram illustrating a method according to an example implementation Figure 3 Flowchart for performing optimization operations during step 165 of . At step 200, for the predicted source operand, it is determined whether any earlier instruction has been submitted that would have produced the desired value as its result value, i.e., the result produced has been used to update the architectural state of the device, either by writing to the appropriate register in the register file, or by submitting a specific mapping to the register renaming table.
[0068] When it is determined that an earlier instruction that produces this value as its result has been committed, then at step 205, it is determined whether the result of the earlier instruction is the same as the predicted source operand value. If not, the process proceeds to step 215, where the instruction is rewound as necessary. Figure 1 In particular, it would be necessary to flush all instructions that were processing based on the predicted source operand values from the pipeline and instead return the state of the processing pipeline to a point before the predicted source operand values were used, and then re-execute the affected instructions based on the actual source operand values.
[0069] However, if it is determined at step 205 that the result of the earlier instruction is the predicted source operand value, then at step 210 the known result value may be committed to the register determined from the destination register identifier of the instruction using the predicted source operand value.
[0070] References Figure 3 and Figure 4 The steps discussed may be performed regardless of the form of the processing pipeline, and in particular may be performed regardless of whether the pipeline implements in-order processing of instructions or out-of-order processing of instructions.
[0071] Existence can be Figure 4 There are many ways to submit a known result value at step 210. Figure 5A An example method that may be used, for example, within an in-order processing system is illustrated. In particular, at step 220, the implementation of the optimization operation may involve causing the execution stage 45 to write a known result value to a register within the register group 50 identified by the destination register identifier without the execution stage actually executing the instruction. In particular, the known result value may be provided directly to the execution stage along with an indication of the register into which the result value should be written.
[0072] Figure 5BThe diagram shows a method that can be used, for example, in an out-of-order system. Figure 4 In particular, at step 225, an implementation of the optimization operation may be used to cause the register renaming circuitry within the register renaming stage 25 to perform a remapping such that the architectural register identified by the destination register identifier of the instruction that has used the predicted source operand value is mapped to the physical register containing the known result value. By performing such a remapping, this may eliminate the need to perform any actual update of any physical register in the register file 50 to implement the known result value. Figure 4 Step 210 is required.
[0073] As previously mentioned, while the above-described remapping performed within the register renaming circuitry in the presence of optimization conditions can only be committed when the predicted source operands have been determined to be correct, additional performance improvements may be achieved by speculatively performing the remapping before the predicted source operand values are determined to be correct. Figure 6 An example implementation of such an optimization operation is shown in FIG. Figure 6 The process replaces Figure 4 process to achieve Figure 3 Step 165.
[0074] At step 250, the register renaming circuitry is caused to speculatively perform a remapping such that the architectural register identified by the destination register identifier of the instruction that has used the predicted source operand value is mapped to the physical register that is expected to store the known result value. At this stage, it may be the case that the physical register in question has not yet been filled with the result value. By way of example only, if we consider a multiplication instruction that specifies architectural source operand registers R3 and R7, the result of which is written to architectural destination register R1, and for purposes of illustration we assume that source register R3 is mapped to physical register P40 by the register renaming circuitry, then if the predicted source operand value for R3 is output by value prediction circuitry 60, and in particular that source operand value is predicted to be 0, then combined with the knowledge that the instruction specifies a multiplication operation, it will be known that the result value to be written to register R1 is also 0. Therefore, the speculative remapping performed at step 250 may remap architectural register R1 to physical register P40. This may be done regardless of whether the earlier instruction that was writing to register R3 has finished execution.
[0075] Then, at step 255, for the predicted source operand, it is determined whether an earlier instruction that produced that value as its result has been committed. If this is true, the process proceeds to step 260, where it is determined whether the result of the earlier instruction is the same as the predicted source operand value. If not, the process proceeds to step 265, where the rewind is performed by Figure 1The processing pipeline of the processor performs processing to correct any speculation based on the predicted source operand values, and in addition, any necessary adjustments are made to the rename table mappings. In particular, with reference to step 250 discussed previously, it may be determined that the speculative remapping that was performed was inappropriate, and instead, the architectural register in question may be mapped to a different arbitrary available physical register.
[0076] If, at step 260, the result of the earlier instruction is determined to be the same as the predicted source operand value, then the process proceeds to step 270, where the speculative remapping performed at step 250 is maintained as a committed remapping, thereby updating the architectural state of the system.
[0077] Except in Figure 3 In addition to the optimization operations performed at step 165 in association with a particular pending instruction using the predicted source operand value, in some cases, further levels of optimization may be performed with respect to certain related instructions, such as by Figure 7 At step 300, the issue stage 30 may be arranged to check the instructions in the issue queue 35 to identify whether there are dependent instructions for the instruction to be processed using the previously discussed optimization operation, i.e., whether there are dependent instructions for pending instructions whose result values are known without executing the pending instruction. Then, at step 305, for any such dependent instructions, if the result of the dependent instruction can be directly derived from the source operands of the dependent instruction given by the result value of the pending instruction processed using the optimization operation, additional speculative remapping may be performed on the architectural register used to store the result of the dependent instruction.
[0078] As a concrete example, consider the following two instructions:
[0079] MUL R1,R3,R4
[0080] MOV R5,R1
[0081] The first multiply instruction is used to multiply the values in architectural registers R3 and R4, with the result being stored in R1. A subsequent move instruction then moves the contents of register R1 into register R5.
[0082] If, for a multiplication instruction, a predicted source operand value of 0 is given for register R3, this is detected by the optimization analyzer 40 as the presence of an optimization-causing condition, since it is known that if the predicted source operand value is correct, the result value to be stored in register R1 will be 0. Figure 6The speculative row remapping performed at step 250 of will in this case remap architectural register R1 to the same physical register associated with architectural register R3, which is assumed for the purpose of illustration to be physical register P40. Then, for the subsequent move instruction, note that this is a dependent instruction because its source operand is architectural register R1. It is also determined that the result can be derived directly from this source operand, which in this case is the same as the source operand. Therefore, a further speculative row remapping can be performed to remap architectural register R5 to the physical register associated with R1, which takes into account that the above remapping is now physical register P40. Therefore, each of registers R3, R1 and R5 is now mapped to physical register P40. If it is discovered at the appropriate time that the earlier instruction that produced the value associated with source register R3 actually produced the value 0, then this will mean that the value 0 will be stored in physical register P40, and the above two speculative remappings of registers R1 and R5 can now be submitted without having to execute the multiplication instruction or the move instruction separately. Therefore, it should be understood that the optimization techniques described herein can produce significant performance improvements in certain situations.
[0083] FIG. 8A to FIG. 8D Some example scenarios in which the previously discussed optimization techniques may be used are illustrated. Fig. 8A A multiply instruction is shown, and in this case, the assumed value prediction circuitry 60 predicts that the source operand to architectural register R3 is 0. Therefore, based on the optimization techniques described previously, this allows architectural register R1 to be mapped to 0, and the mapping to be committed once it is known that the contents of R3 are in fact 0.
[0084] Figure 8B An addition or subtraction example is illustrated, and again the source operand value associated with architectural register R3 is predicted to be 0. In this case, architectural register R1 can be mapped to architectural register R2. For the register renaming example implementation discussed previously, this would involve mapping the physical register associated with architectural register R1 to the same physical register associated with architectural register R2. This mapping can be committed once it is known that architectural register R3 is 0.
[0085] Figure 8C A multiply-accumulate instruction is illustrated. According to this encoding, registers R2 and R3 provide source operand values to be multiplied together to produce an intermediate result, which is then added to the current accumulation value in register R1 to produce a result value, which is then written back to register R1. In this illustrated example, it is assumed that the value prediction circuit 60 predicts that the value associated with architectural register R2 is 0. This implies that no update is required to the contents associated with architectural register R1, and this can be confirmed once the contents of R2 are known to be 0.
[0086] Fig.8D A multiplication example is illustrated, where the values in registers R2 and R4 are multiplied together to produce a result that is written to register R1. In this case, it is assumed that the value prediction circuit predicts that the value associated with register R2 is 1. With this information, it is then known that the result to be written to R1 will be the value stored in R4, and therefore R1 will be mapped to R4, a mapping that is committed once the value in R2 is known to be 1.
[0087] As previously discussed, the above optimization techniques may be employed in both in-order and out-of-order systems. Furthermore, the above optimization techniques may be employed in scalar systems or in vector processing systems in which processing operations are performed in parallel in multiple processing lanes, each lane receiving a particular data element from a vector of data elements forming each source operand. Fig. 9 As shown, the above optimization techniques can be implemented independently in each parallel processing channel. Fig. 9 In the example of FIG, four parallel processing lanes 350, 355, 360, 365 are shown, and source value prediction is performed with respect to source data elements used in each respective lane. Based on the source value prediction, optimization checks 370, 375, 380, 385 may be performed independently for each lane by the optimization analyzer 40, so that the above-described optimization processing can be performed on a lane-by-lane basis depending on whether an optimization condition is detected for that lane. This can result in power consumption savings when performing vector processing operations by enabling processing in one or more lanes to be turned off, because the result value is known within such lanes without performing data processing operations.
[0088] Based on the above examples, it should be understood that the techniques described herein enable additional performance benefits to be achieved in microarchitectures that employ value prediction schemes. In particular, value prediction not only enables certain source operand values to become available earlier than otherwise, but also, when the predicted source operand value is a particular value, the particular value, combined with the operation required by the associated pending instruction, means that the result value is known without performing the operation, and this information can then be used to avoid the execution of the instruction. In addition, the knowledge of the result value can be used to allow further speculation about the associated instructions that can use the result value as a source operand.
[0089] Although in principle optimization conditions can be detected based on the actual source operand values and associated operations of the selected pending instruction, the achievable performance benefits will usually be limited because many source operand values are actually created by adjacent instructions in the instruction stream. However, by using predicted source operand values, this dependency on earlier instruction execution is no longer needed. In particular, the predicted source operand values may be significantly available before the actual source operand values, so the above-mentioned technology enables optimization conditions to be detected at an early stage, thereby significantly improving the achievable performance benefits.
[0090] In this application, the words "configured to..." are used to mean that the elements of a device have a configuration that enables the defined operation to be performed. In this context, "configuration" means the arrangement or manner of interconnection of hardware or software. For example, a device may have dedicated hardware that provides the defined operation, or a processor or other processing device may be programmed to perform the function. "Configured to" does not imply that the elements of the device need to be changed in any way to provide the defined operation.
[0091] Although illustrative embodiments of the present invention have been described in detail herein with reference to the accompanying drawings, it should be understood that the present invention is not limited to those precise embodiments and that various changes, additions and modifications may be implemented therein by those skilled in the art without departing from the scope and spirit of the present invention as defined by the appended claims. For example, various combinations of the features of the independent claims can be made with the features of the dependent claims without departing from the scope of the present invention.
Claims
1. A device for processing instructions, include: execution circuitry for executing instructions, each instruction requiring one or more source operand values to perform an associated operation to produce a result value; issue circuitry for maintaining an issue queue of pending instructions awaiting execution by said execution circuitry; prediction circuitry for generating a predicted source operand value for a pending instruction selected in the issue queue, wherein an associated operation required by the selected pending instruction comprises an arithmetic operation performed using a plurality of source operand values including the predicted source operand value to produce the result value; and optimization circuitry for detecting an optimization condition for the selected pending instruction when: the predicted source operand value is such that the result value is a known result value that is known without performing the associated operation, taking into account the associated operation required by the selected pending instruction; wherein the optimization circuit is arranged to: in response to detecting the optimization condition, implement the optimization operation instead of causing the execution circuit to perform the association operation to execute the selected pending instruction; The selected pending instruction provides a destination register identifier, and the optimization operation includes: once the predicted source operand value is determined to be correct, submitting the known result value to a register determined according to the destination register identifier.
2. The device according to claim 1, in: Each instruction is arranged to identify the one or more source operand values by providing an associated source register identifier; the selected pending instruction provides, for the source operand predicted by the prediction circuitry, a source register identifier that is a destination register identifier of an earlier instruction in a sequence of instructions to be executed by the execution circuitry; and Once the result value is determined for the earlier instruction and the result value matches the predicted source operand value, the predicted source operand value for the selected pending instruction is determined to be correct.
3. The device according to claim 1 or claim 2, in, The optimisation circuitry is arranged to implement the optimisation operation by causing the execution circuitry to write the known result value to the register determined in accordance with the destination register identifier.
4. The device according to claim 1 or claim 2, in, The apparatus supports speculative execution of the instructions by the execution circuitry out of order relative to an original program order of the instructions, the apparatus further comprising: register renaming circuitry for mapping an architectural register identified by a register identifier in the instruction to a physical register in a physical register set, wherein the number of physical registers exceeds the number of architectural registers; and The optimisation circuitry is arranged to implement the optimisation operation by causing the register renaming circuitry to perform a remapping such that the architectural register identified by the destination register identifier is mapped to a physical register containing the known result value.
5. The device according to claim 4, in, The optimisation circuitry is arranged to speculatively perform the remapping before the predicted source operand value is determined to be correct, and then commit the remapping when the predicted source operand value has been determined to be correct.
6. The device according to claim 5, in, The remapping is used to trigger further optimization operations for at least one dependent instruction, the at least one dependent instruction using a result value of the selected pending instruction as a source operand.
7. The device according to claim 6, in, The at least one dependent instruction is a move instruction that identifies the result value of the selected pending instruction as a source operand, and the further optimization operation causes the register renaming circuitry to perform further remapping such that an architectural register identified by a destination register identifier of the move instruction is also mapped to a physical register containing the known result value.
8. The device according to any one of the preceding claims, in, The association operation is such that when the predicted source operand value is a predetermined value, the known result value is given by one of the source operand values.
9. The device according to claim 8, in, The predetermined value is 0.
10. The device according to claim 9, in, The selected pending instruction is a multiplication instruction, and when the predicted source operand value is zero, the known result value is zero.
11. The device according to claim 9, in: The selected pending instruction is a multiply-accumulate instruction requiring multiplying a first source operand and a second source operand together to form an intermediate result, which is then added to an accumulation source operand; For one of the first source operand and the second source operand, the predicted source operand value is zero; and The known result value is provided by the accumulation source operand.
12. The device according to claim 11, in: The destination register identifier is also used as a source operand identifier for the accumulation source operand; and Submitting the known result value to a register determined according to the destination register identifier includes maintaining the contents of the register unchanged.
13. The device according to claim 9, in: The selected pending instruction is an addition or subtraction instruction that operates on a first operand and a second operand; For one of the first operand and the second operand, the predicted source operand value is zero; and The known result value is determined based on a value of the other of the first operand and the second operand.
14. The device according to claim 8, in, The predetermined value is 1.
15. The device according to claim 14, in: The selected pending instruction is a multiplication instruction that operates on a first operand and a second operand; For one of the first operand and the second operand, the predicted source operand value is 1; and The known result value is given by the value of the other of the first operand and the second operand.
16. Apparatus according to any one of the preceding claims, in: The optimisation circuitry is further arranged to identify a dependent instruction in the issue queue which uses the result value of the selected pending instruction as a source operand and to identify the known result value as the source operand such that the issue circuitry considers the source operand to be available for the dependent instruction.
17. Apparatus according to any one of the preceding claims, in, The execution circuitry is arranged to perform vector processing operations in a plurality of parallel processing lanes, and the optimisation circuitry is arranged to evaluate, for each lane, whether the optimisation condition exists, to enable the optimisation operation to be applied to any lane for which a source operand value predicted, given the associated operation of the selected pending instruction, causes a result value for the lane to be known without performing the associated operation.
18. A method for processing an instruction, include: providing execution circuitry to execute the instructions, each instruction requiring one or more source operand values to be used to perform an associated operation to produce a result value; maintaining an issue queue of pending instructions awaiting execution by said execution circuitry; employing prediction circuitry to generate a predicted source operand value for a pending instruction selected in the issue queue, wherein an associated operation required by the selected pending instruction comprises an arithmetic operation performed using a plurality of source operand values, the plurality of source operand values including the predicted source operand value, to produce the result value; detecting an optimization condition for the selected pending instruction when: the predicted source operand values are such that the result value is a known result value that is known without performing the associated operation, taking into account the associated operation required by the selected pending instruction; and In response to detecting the optimization condition, implementing an optimization operation instead of causing the execution circuitry to perform the associated operation to execute the selected pending instruction, The selected pending instruction provides a destination register identifier, and the optimization operation includes: once the predicted source operand value is determined to be correct, submitting the known result value to a register determined according to the destination register identifier.
19. A device for processing instructions, include: an execution device for executing instructions, each instruction requiring one or more source operand values to perform an associated operation to produce a result value; issuing means for maintaining an issuing queue of pending instructions waiting to be executed by said executing means; prediction means for generating a predicted source operand value for a pending instruction selected in the issue queue, wherein an associated operation required by the selected pending instruction comprises an arithmetic operation performed using a plurality of source operand values including the predicted source operand value to produce the result value; and an optimization device for detecting an optimization condition for the selected pending instruction when: the predicted source operand value is such that the result value is a known result value that is known even without performing the associated operation, taking into account the associated operation required by the selected pending instruction; wherein the optimization means is arranged to: in response to detecting the optimization condition, implement the optimization operation instead of causing the execution means to perform the association operation to execute the selected pending instruction; The selected pending instruction provides a destination register identifier, and the optimization operation includes: once the predicted source operand value is determined to be correct, submitting the known result value to a register determined according to the destination register identifier.
