Optimizing captured loops in a processor to optimize loop playback performance - Patents.com

The loop buffer circuit enhances loop performance in processors by capturing and optimizing loops within the instruction pipeline, addressing visibility limitations and power consumption issues.

JP2024544599APending Publication Date: 2024-12-03MICROSOFT TECHNOLOGY LICENSING LLC
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
JP2024531024
Authority / Receiving Office
JP · JP
Patent Type
Applications
Current Assignee / Owner
Priority Date
2021-12-23
Filing Date
2022-09-19
Publication Date
2024-12-03

AI Technical Summary

Technical Problem

Conventional processors face challenges in optimizing loop performance due to limited visibility of instructions outside the instruction pipeline, which hinders effective code optimizations and increases power consumption.

Method used

The implementation of a loop buffer circuit that detects and captures loops within the instruction pipeline, allowing for expanded visibility of instructions and performing optimizations such as instruction fusion, loop-invariant instruction removal, critical instruction scheduling, and software prefetching to enhance loop playback performance.

Benefits of technology

This approach reduces the number of instructions required for loop iterations, minimizes power consumption, and improves computational throughput by optimizing loop execution.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 2024544599000001_ABST
    Figure 2024544599000001_ABST
Patent Text Reader

Abstract

Optimization of a captured loop in a processor to optimize loop playback performance, and related methods and computer-readable media, are disclosed. The processor includes a loop buffer circuit configured to detect a loop. In response to the detected loop, the loop buffer circuit is configured to capture loop instructions in the detected loop and replay the captured loop instructions in an instruction pipeline to be processed and executed for a subsequent iteration of the loop. The loop buffer circuit is configured to determine whether loop optimization can be performed based on the captured loop to improve loop playback performance. If the loop buffer circuit determines that loop optimization can be performed based on the captured loop, the loop buffer circuit is configured to perform such loop optimization so that such loop optimization can be realized when replaying the captured loop to improve playback performance of the captured loop.
Need to check novelty before this filing date? Find Prior Art

Description

[Technical field]

[0001] The techniques of this disclosure relate generally to performing loop buffering (ie, loop detection and playback) for loops in computer software instructions processed in a processor. [Background technology]

[0002] Microprocessors, also known as "processors," perform computational tasks for a wide variety of applications. A conventional microprocessor includes a central processing unit (CPU) that includes one or more processor cores, also known as "CPU cores," that execute software instructions. The software instructions instruct the CPU to perform operations based on data. The CPU performs the operations according to the instructions to generate a result, which is a generated value. Processors employ instruction pipelining as a processing technique that can increase the throughput of instructions executed by the processor by dividing the processing of each instruction into a series of steps. These steps are performed in one or more instruction pipelines that are comprised of multiple stages in the instruction processing circuitry. In this regard, the instruction processing circuitry in the processor includes an instruction fetch circuit configured to fetch instructions to be executed from an instruction memory (e.g., a system memory or an instruction cache memory). The fetched instructions are decoded in a decoded state and inserted into the instruction pipeline where they are preprocessed before reaching the execution circuitry to be executed.

[0003] Many modern high performance processors deploy loop buffers for further pipeline optimization and power savings. A loop is defined as any sequence of instructions in a pipeline whose processing is repeated sequentially in consecutive operations. For example, a loop can occur based on a loop construct in programming software, which is then compiled into instructions that cause the looping behavior according to its processing. FIG. 1 shows an example of an instruction stream 100 of instructions including an exemplary loop 102. The loop 102 is a "while" loop that begins with a while instruction 104 having a condition that is evaluated as it is processed. Instructions 106-112 within the loop 102 are executed, and continue to execute within the loop if the condition of the while instruction 104 evaluates to true. The loop 102 exits the while instruction 104 as an exit branch instruction in response to the condition of the while instruction 104 evaluating to false, and proceeds to the next instruction 114 at the exit target address. If a loop, such as loop 102 in Figure 1, can be detected in a pipeline, the instructions in the loop can be captured and replayed for the number of iterations the loop is processed before the loop terminates, without the need to refetch and re-decode such instructions, since the loop contains the same sequence of instructions that were already fetched and decoded for the first iteration of the loop. In this manner, the fetch and decode stages of the pipeline can be deactivated or stopped to conserve pipeline power when a loop can be detected and replayed.

[0004] In this regard, many processors include a loop buffer in the instruction pipeline that includes a loop detection circuit and a loop replay circuit. The loop detection circuit is configured to identify repeated instruction sequences in an instruction stream processed in the instruction pipeline to detect loops. In response to detecting a loop, the loop capture circuit is configured to capture the instruction sequence in the detected loop in the loop buffer. The loop replay circuit is then configured to replay such captured instructions from the loop buffer in the instruction pipeline for a defined number of loop iterations (called a "trip count") or indefinitely depending on the design, without the need to refetch and re-decode such captured instructions. The fetch and decode stages of the instruction pipeline can be resumed once the loop has finished, initiating conventional fetch and decode instructions starting from the end of the detected loop.

[0005] It is also conventional to perform optimizations on program code executed within a processor to improve computational performance. Performing code optimizations on instructions within a loop can be particularly advantageous since the performance benefits of such code optimizations are realized at each iteration of the loop within the processor. During compilation, a compiler can analyze instructions within the program code to perform certain code optimizations on instructions within the program code to improve performance. For example, a compiler can condense certain instructions into fewer instructions or instructions that can be executed in fewer clock cycles to optimize operational performance. The optimized instructions can be compiled into executable binary program code executed by the processor. To perform such code optimizations, the compiler has visibility into all instructions within the program code. However, the compiler may not have access to run-time information that is generated during the actual execution of instructions within the program code. For example, the program code may include a conditional branch instruction that executes one of a number of different instruction flow paths depending on the outcome of a condition specified in the conditional branch instruction. Execution of the conditional branch instruction may result in, for example, a loop. The termination of the loop may also be controlled by the conditional branch instruction. Run-time knowledge of the actual instruction flow paths resulting from the processing of the conditional branch instruction within the instruction pipeline may be used to perform additional code optimizations. However, the processor only has knowledge of the instructions that are present in the instruction pipeline at any one time. The processor has no knowledge of instructions that have not yet been fetched. This limited visibility can adversely affect the processor's ability to perform certain code optimizations that require additional knowledge of instructions that have not yet been fetched into the instruction pipeline. Furthermore, in the example of code optimization of a loop, the instructions that form the loop may be distributed across different pipeline stages of the instruction pipeline, making it impossible or infeasible to perform code optimization of the loop. Summary of the Invention

[0006] Exemplary aspects disclosed herein include optimizing captured loops in a processor to optimize loop replay performance. Related methods and computer-readable media are also disclosed. The processor includes an instruction processing circuit configured to fetch computer program instructions ("instructions") into an instruction stream in an instruction pipeline for processing and execution. The instruction stream may include a loop. A loop is a sequence of instructions in the instruction stream that repeats sequentially in a consecutive arrangement. The instruction processing circuit includes a loop buffer circuit configured to detect the loop. In response to the detected loop, the loop buffer circuit is configured to capture loop instructions in the detected loop and insert (i.e., replay) the captured loop instructions into the instruction pipeline to be processed and executed for a subsequent iteration of the loop. In this manner, the instructions in the loop may not need to be re-fetched and re-processed, for example, for a subsequent iteration of the loop. In an exemplary aspect, the loop buffer circuit is configured to determine whether loop optimization can be performed based on the captured loop to improve performance of the loop replay, and to perform the loop optimization if so. Because the captured loop may contain more instructions for the captured loop than are present in the instruction pipeline or a particular pipeline stage for processing at a given time, the processor may use this expanded visibility of more instructions in the captured loop to the loop buffer circuit to determine loop optimizations for the loop. These loop optimizations may not otherwise be determinable at compile time and / or run time based solely on knowledge of the presence of particular instructions of the loop in the instruction pipeline. In this regard, if the loop buffer circuit determines whether a loop optimization can be performed based on the captured loop, the loop buffer circuit is configured to modify at least one instruction in the captured loop to generate an optimized loop. The optimized loop may be replayed in the instruction pipeline when the loop is reprocessed and re-executed in the instruction pipeline on an iteration, thus allowing the loop optimization to be realized by the processor.

[0007] In one exemplary aspect, the loop buffer circuit includes a loop optimization circuit configured to determine loop optimizations for the captured loop by performing a loop post-capture instruction transformation analysis of instructions within the captured loop. The loop post-capture instruction transformation analysis determines whether such instructions can be transformed (e.g., modified outside the loop, merged, removed, etc.) to affect the loop optimization when the captured loop is replayed. If the loop post-capture instruction transformation analysis determines that instructions can be transformed to affect the loop optimization, such instructions are transformed by the loop buffer circuit such that such loop optimization is realized when the transformed instructions are replayed as part of the replay of the captured loop. For example, the loop buffer circuit can be configured to determine whether any instructions within the captured loop can be fused (i.e., merged or combined) into fewer instructions or a single instruction that is inserted into the instruction pipeline when the loop is replayed. This allows the captured loop to be replayed with fewer instruction processing than the original captured loop. For example, a producer instruction in a captured loop identified as having a target operand that is a source operand of a younger consumer instruction may be merged with the consumer instruction to reduce the number of instructions in the loop for a replayed iteration of the captured loop. In this manner, the loop buffer circuit may merge instructions in the loop. Such merged instructions may not be identifiable if they are not present in a pipeline stage of the instruction pipeline and / or are separated by a sufficient code distance to be unidentifiable. The loop buffer circuit may be configured to identify instructions that can be merged not only within the same replayed iteration of the loop, but also across different iterations of the replayed loop (i.e., across iterations).

[0008] In another exemplary aspect, the loop buffer circuit includes a loop optimization circuit configured to perform a loop post-capture instruction transformation analysis of the instructions in the captured loop by detecting whether the instruction is loop invariant to produce the same result for each replay iteration of the captured loop. In that case, this means that such loop invariant instructions can be transformed to be moved by the loop buffer circuit outside the captured loop and replayed only once regardless of the number of times the captured loop is replayed as a loop optimization. An example of such an instruction is an instruction that generates a constant value. In another exemplary aspect, the loop buffer circuit is configured to perform a loop post-capture analysis of the instructions in the captured loop to detect whether any instruction can be transformed into another instruction with reduced instruction strength. This means that it takes fewer clock cycles to execute in order to produce the same result for the operation. An example of such an instruction is a multiplication instruction that doubles a source. In this example, the multiplication instruction can be transformed and replaced with an instruction that left-shifts the value of the source by one bit as an instruction that takes fewer clock cycles to execute. In this way, the replay of the captured loop replays a transformed instruction that takes fewer clock cycles to process and execute than the original instruction in the captured loop.

[0009] In another exemplary aspect, the loop buffer circuit includes a loop optimization circuit configured to perform a loop post-capture instruction transformation analysis of instructions in the captured loop to detect critical timing instructions. The loop buffer circuit is configured to transform such identified critical instructions with scheduling hints that are used by a scheduling circuit in the instruction pipeline to prioritize issuance for execution when replayed. For example, instructions in the captured loop identified as performing a critical load are critical instructions whose timing impacts other dependent instructions and can be transformed with scheduling hints so that these instructions are scheduled to execute earlier in the replay. An example of a critical load instruction is a load instruction whose generated result is consumed by a conditional branch instruction. The generated result of the load instruction is necessary to resolve the prediction of the conditional branch instruction. Thus, in the case of a conditional branch instruction, faster replay and execution of the critical load instruction can result in faster resolution of the mispredicted conditional branch instruction. Another example of a critical instruction that can benefit from scheduling hints is an instruction identified as having a dependency chain in the captured loop, and the marking of the key unlock instruction is critical.

[0010] In another exemplary aspect, the loop optimization circuit is configured to determine loop optimizations for the captured loop by performing a loop post-capture instruction analysis of instructions in the captured loop. An instruction execution slice in the captured loop is a set of instructions in the captured loop that calculates load / store memory addresses required for memory load / store instructions executed in the replay of the captured loop. Memory loads and stores in the replay loop that cause cache misses will degrade the throughput performance of the instruction pipeline when the loop is replayed. However, memory loads and stores in the replay loop that cause more frequent cache misses may increase the degradation of the throughput performance of the instruction pipeline as a function of the number of replay iterations. Thus, in this example, the loop buffer circuit can be configured to extract an identified instruction execution slice identified among the instructions of the captured loop. The loop buffer circuit is configured to convert the identified extracted instruction execution slice into a software prefetch instruction, which can then be injected into a prefetch stage in the instruction pipeline when the captured loop is replayed to perform the loop optimizations for the captured loop. Processing a software prefetch instruction for an instruction execution slice causes the processor's instruction processing circuitry to execute the extracted instruction in the instruction execution slice as a prefetch instruction earlier in the instruction pipeline. Thus, cache misses resulting from memory operations performed by processing the extracted execution slice instruction as a prefetch instruction can be recovered sooner to be consumed by dependent instructions when the captured loop is replayed. The extracted instruction execution slice can be stored in a buffer separate from the loop buffer circuitry or in the loop buffer circuitry with a special identifier (e.g., by additional pointer bits) that is used to generate the software prefetch instruction, for example.

[0011] In this regard, in one exemplary aspect, a processor is provided. The processor includes an instruction processing circuit configured to process an instruction stream including a plurality of instructions in an instruction pipeline. The instruction processing circuit includes a loop buffer circuit. The loop buffer circuit is configured to detect a loop including a plurality of loop instructions among the plurality of instructions in the instruction stream. In response to detecting the loop in the instruction stream, the loop buffer circuit is configured to capture the plurality of loop instructions of the detected loop as a captured loop. The loop buffer circuit is configured to determine whether loop optimization can be performed on the captured loop based on the captured loop. In response to determining that loop optimization can be performed on the captured loop, the loop buffer circuit is configured to modify the captured loop to generate an optimized loop. The loop buffer circuit is configured to determine whether the captured loop is to be replayed in the instruction pipeline. In response to determining that the captured loop is to be replayed in the instruction pipeline, the loop buffer circuit is configured to insert the optimized loop into the instruction pipeline to be replayed.

[0012] In another exemplary aspect, a method replays an optimized loop based on a captured loop in an instruction pipeline in a processor. The method includes detecting a loop including a plurality of loop instructions among a plurality of instructions in an instruction stream including a plurality of instructions in the instruction pipeline. The method also includes, in response to detecting the loop in the instruction stream, capturing the plurality of loop instructions of the detected loop as a captured loop and determining whether loop optimization can be performed on the captured loop based on the captured loop, and in response to determining that loop optimization can be performed on the captured loop, modifying the captured loop to generate the optimized loop. The method further includes determining whether the captured loop is to be replayed in the instruction pipeline. The method further includes, in response to determining that the captured loop should be replayed in the instruction pipeline, inserting the optimized loop into the instruction pipeline to be replayed.

[0013] In another exemplary aspect, a non-transitory computer-readable medium having stored thereon computer-executable instructions that, when executed by a processor, cause the processor to: detecting a loop including a plurality of loop instructions among a plurality of instructions in an instruction stream including a plurality of instructions in an instruction pipeline; In response to detecting a loop in the instruction stream, Capture multiple loop instructions of the detected loop as captured loops, determining whether loop optimization can be performed on the captured loop based on the captured loop; modifying the captured loop to generate an optimized loop in response to determining that a loop optimization can be performed on the captured loop; determining whether the captured loop should be replayed in the instruction pipeline; responsive to determining that the captured loop should be replayed within the instruction pipeline, causing the optimized loop to be inserted into the instruction pipeline to be replayed; causes an optimized loop to be regenerated based on a captured loop in an instruction pipeline in the processor.

[0014] Those skilled in the art will appreciate the scope of the present disclosure and realize additional aspects thereof upon reading the following detailed description of the preferred embodiments in connection with the accompanying drawing figures. [Brief description of the drawings]

[0015] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate several aspects of the disclosure and, together with the description, serve to explain the principles of the disclosure. [Figure 1] 2 is a diagram of an exemplary loop of computer program instructions within an instruction stream. [Diagram 2] FIG. 1 is a diagram of an exemplary processor including an exemplary instruction processing circuit including one or more instruction pipelines for processing computer instructions for execution, the processor further including a loop buffer circuit configured to detect and capture loops in an instruction stream in the instruction pipelines, determine whether loop optimizations are possible based on the captured loops to improve performance of replaying the loops, and replay the optimized loops based on the captured loops using such loop optimizations in the instruction pipelines. [Diagram 3] FIG. 3 is a diagram of an exemplary loop buffer circuit that may be provided within the instruction processing circuit of FIG. 2, including a loop detection circuit configured to detect loops in an instruction stream in the instruction pipeline, a loop capture circuit configured to capture instructions for the detected loops, a loop optimization circuit configured to identify and perform loop optimizations based on the captured loops, and a loop playback circuit configured to play back optimized loops based on the captured loops using such loop optimizations in the instruction pipeline. [Figure 4]3 is a flowchart illustrating an example process of a loop buffer circuit in the processor of FIG. 2 that captures detected loops and performs loop optimizations that are determined to be possible based on the captured loops to improve performance of replay of the optimized loops in the processor's instruction pipeline. [Figure 5A] FIG. 2 is a diagram of an example captured loop of computer program instructions, including available instruction fusion loop optimizations that can be identified and implemented by transforming instructions within the captured loop. [Figure 5B] FIG. 5B is a diagram of an optimization loop of the captured loop of FIG. 5A including instructions transformed to provide instruction fusion loop optimization for the captured loop. [Figure 6] 3 is a flowchart illustrating an example process of a loop buffer circuit in the processor of FIG. 2 for implementing a determined loop optimization by capturing a detected loop, transforming instructions in the captured loop to generate an optimized loop for replay, and improving performance of the replay of the captured loop in the instruction pipeline of the processor. [Figure 7A] FIG. 2 is a diagram of an example captured loop of computer program instructions, including available instruction sequence loop optimizations that can be identified and implemented by transforming the instructions within the captured loop. [Figure 7B] FIG. 7B is a diagram of an optimization loop of the captured loop of FIG. 7A with instructions transformed to provide instruction sequence loop optimization for the captured loop. [Figure 8A] FIG. 2 is a diagram of an example captured loop of computer program instructions, including available critical instruction loop optimizations that can be identified and implemented by transforming the instructions within the captured loop. [Figure 8B] FIG. 8B is a diagram of the captured loop optimization loop of FIG. 8A with instructions transformed to include a scheduling hint of the critical instruction to the captured loop to provide a critical instruction loop optimization of the captured loop. [Figure 9A] FIG. 2 illustrates an example captured loop of computer program instructions including instruction execution slices that can be identified and realized by generating and injecting software prefetch instructions that represent the instruction execution slices within a prefetch stage of an instruction pipeline. [Figure 9B] FIG. 9B is an optimized loop diagram of the captured loop of FIG. 9A in which detected instruction execution slices in the captured loop are removed from the captured loop and converted to software prefetch instructions. [Figure 10] FIG. 3 is a diagram of another exemplary loop buffer circuit that may be provided within the instruction processing circuit of FIG. 2, wherein the loop optimization circuit is configured to detect an instruction execution slice within the captured loop and generate and inject a software prefetch instruction representing the instruction execution slice within a prefetch stage of the instruction pipeline as part of the optimization loop, and the instruction entry in the loop buffer circuit includes an execution pointer field configured to store a pointer identifying the instruction as part of the instruction execution slice and identifying the next instruction in the captured loop as part of the detected execution slice instruction in the captured loop. [Figure 11] FIG. 11 is a flowchart illustrating an exemplary process of the loop buffer circuit of FIG. 10 for capturing a detected loop, detecting an instruction execution slice within the captured loop as an available loop optimization, and generating and injecting software prefetch instructions representing instructions within the detected instruction execution slice in a prefetch stage of an instruction pipeline as part of the optimization loop to achieve such loop optimization when the captured loop is replayed. [Figure 12]FIG. 13 is a block diagram of an exemplary processor-based system including a processor including instruction processing circuitry for executing instructions from program code, the processor including a loop buffer circuit, including but not limited to the loop buffer circuit of FIG. 2, FIG. 3, and / or FIG. 10, configured to detect and capture loops in an instruction stream in an instruction pipeline, determine whether loop optimizations can be performed based on the captured loops to improve performance of the loop replay, and replay the optimized loops using such loop optimizations in the instruction pipeline. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS

[0016] Aspects disclosed herein include optimizing captured loops in a processor to optimize loop replay performance. Related methods and computer-readable media are also disclosed. The processor includes an instruction processing circuit configured to fetch computer program instructions ("instructions") into an instruction stream in an instruction pipeline for processing and execution. The instruction stream may include a loop. A loop is a sequence of instructions in the instruction stream that repeats sequentially in a consecutive arrangement. The instruction processing circuit includes a loop buffer circuit configured to detect the loop. In response to the detected loop, the loop buffer circuit is configured to capture loop instructions in the detected loop and insert (i.e., replay) the captured loop instructions into the instruction pipeline to be processed and executed for a subsequent iteration of the loop. In this manner, the instructions in the loop may not need to be re-fetched and re-processed, for example, for a subsequent iteration of the loop. In an exemplary aspect, the loop buffer circuit is configured to determine whether loop optimization can be performed based on the captured loop to improve performance of the loop replay, and to perform the loop optimization if so. Because the captured loop may contain more instructions for the captured loop than are present in the instruction pipeline or a particular pipeline stage for processing at a given time, the processor may use this expanded visibility of more instructions in the captured loop to the loop buffer circuit to determine loop optimizations for the loop. These loop optimizations may not otherwise be determinable at compile time and / or run time based solely on knowledge of the presence of particular instructions of the loop in the instruction pipeline. In this regard, if the loop buffer circuit determines whether a loop optimization can be performed based on the captured loop, the loop buffer circuit is configured to modify at least one instruction in the captured loop to generate an optimized loop. The optimized loop may be replayed in the instruction pipeline when the loop is reprocessed and re-executed in the instruction pipeline on an iteration, thus allowing the loop optimization to be realized by the processor.

[0017] FIG. 2 is a diagram of an exemplary processor 200 within a processor-based system 202, which includes one or more instruction pipelines I0-I1 for execution. N The instruction processing circuit 204 includes an instruction processing circuit 204 configured to process computer instructions 206 in an instruction stream 208 fetched into the instruction pipeline 100. As described in more detail below, the instruction processing circuit 204 includes a loop buffer circuit 210 configured to detect and capture loops in the instruction stream 208. The loop buffer circuit 210 is configured to determine whether loop optimizations can be performed based on the captured loops to improve performance of the loop playback. The loop buffer circuit 210 is configured to process the instruction pipelines I0-I1. N 2, which detects and captures loops in instruction stream 206 and determines whether loop optimizations can be performed based on the captured loops to improve loop replay performance, other aspects of processor 200 and its instruction processing circuitry 204 are first described below.

[0018] The processor 200 of FIG. 2 includes an instruction processing circuit 204 that includes circuitry configured to fetch and process computer program code instructions (referred to as "instructions") to be executed. The instruction processing circuit 204 may be an out-of-order processor, as an example. The instruction processing circuit 204 includes an instruction fetch circuit 212 as a pipeline stage configured to fetch instructions 206 from an instruction memory 214. The instruction memory 214 may be provided within or as part of a main memory of the processor-based system 202. An instruction cache 216 may be provided in the processor-based system 202 to cache the instructions 206 fetched from the instruction memory 214 to reduce timing delays in the instruction fetch circuit 212. The instruction fetch circuit 212 of this example is configured to provide the instructions 206 as fetched instructions 206F to one or more instruction pipeline loop iteration predictions as an instruction stream 208 in the instruction processing circuit 204 to be preprocessed before the fetched instructions 206F reach the execution circuit 218 as another pipeline stage to be executed. The instruction processing circuit 204 also includes an instruction decode circuit 220 as another pipeline stage configured to decode the fetched instruction 206F fetched by the instruction fetch circuit 212 into a decoded instruction 206D. The instruction type and required action encoded in the decoded instruction 206D determines which instruction pipeline I0-I1 the decoded instruction 206D is to be routed to. N This may be used to determine which

[0019] 2, once the fetched instruction 206F is decoded into a decoded instruction 206D by the instruction decode circuitry 220, the decoded instruction 206D is provided to a rename / allocate circuitry 222 as another pipeline stage within the instruction processing circuitry 204. The rename / allocate circuitry 222 is configured to determine whether register names in the decoded instruction 206D need to be renamed to break register dependencies that prevent parallel or out-of-order processing. The rename / allocate circuitry 222 also invokes a register map table (RMT) 224 to rename logical source register operands and / or map destination register operands of the decoded instruction 206D to available physical registers P0-P1 in a physical register file (PRF) 226. X The RMT 224 includes a plurality of mapping entries, each of which is configured to write to a respective logical register R0-R P The mapping entries are mapped to (i.e. associated with) the physical registers P0 to P X The physical registers P0 to P X includes data entries 228(0)-228(X) configured to store data for source and / or destination register operands of decoded instruction 206D.

[0020] Continuing to refer to FIG. 2, the instruction pipelines I0 to I N The issue circuitry 230, as another pipeline stage in the DMA controller 210, identifies and arbitrates between the decoded instructions 206D that have all their source operations ready, and then dispatches the decoded instructions 206D to the execution circuitry 218 when they are ready (i.e., when the source operands are available). The results produced from the execution of the decoded instructions 206D are stored in memory or logical registers R0-R1, while the destination of the executed instruction 206E is stored in memory or logical registers R1-R2.P The instruction pipelines I0 to I1 are written back to the memory 232 and / or the PRF 226 depending on whether the instruction pipeline is N If the fetched instructions 206F and / or decoded instructions 206D present in are no longer valid for some reason, such as a resolved mispredicted branch instruction, then the execution circuitry 218 is configured to issue a flush event 234 to the instruction fetch circuitry 212 to indicate new instructions 206 to be fetched for processing and execution.

[0021] The instructions 206 in the instruction stream 208 may include loops. A loop is a sequence of instructions 206 in the instruction stream 208 that repeat (i.e., are processed) sequentially in a consecutive arrangement. A loop may be present in the instruction stream 208 as a result of a programmed software construct that is compiled into a loop between the instructions 206. A loop may be present in the instruction stream 208 even if it is not part of a higher level programmed software construct, such as based on binary instructions that result from compilation of a higher level programmed software construct. When an instruction 206 is inserted into the instruction pipeline I0-I1, the instruction 206 may be inserted into the instruction pipeline I2. N If instructions 206 that are part of a loop can be detected when they are processed in the instruction pipeline I0 to I1, then these instructions 206 are N A processing stage within the instruction stream 208 may capture and replay such instructions 206 in the instruction stream 208, for example, for a subsequent iteration of the loop, without refetching and / or re-decoding such instructions 206. Note that a loop may contain additional inner loops. Thus, a sequence of instructions 206 that is detected and captured as a captured loop may capture one pass of the loop, and thus appear to be a branchless loop body with no further inner branches. For example, if a loop has alternating conditions for taken and not taken branches, two loops may be captured to represent the entire loop.

[0022] In this regard, the instruction processing circuitry 204 of this example includes a loop buffer circuit 210 for performing loop buffering. As will be described in more detail below, the loop buffer circuit 210 buffers instruction pipelines I0-I1 as an instruction stream 208 for processing and execution. N The loop buffer circuit 210 is configured to detect loops among instructions 206 fetched into the instruction stream 208. In response to a detected loop, the loop buffer circuit 210 is configured to capture (i.e., loop buffer) and replay the instructions 206 in the detected loop, such that processing of these instructions 206 is routed to instruction pipelines I0-I1. N In this regard, the loop buffer circuit 210 may buffer the captured loop instructions 206 in the instruction pipelines I0-I1 for each iteration of the loop. N In this manner, the instructions 206 in the captured loop do not need to be re-fetched and / or re-decoded, for example, for a subsequent iteration of the loop. Thus, loop buffering may save power by not requiring the instruction fetch circuitry 212 to re-fetch the instructions 206 in the detected loop for a subsequent iteration of the loop. Loop buffering may also save power by not requiring the instruction decode circuitry 220 to re-decode the instructions 206 in the detected loop for a subsequent iteration of the loop.

[0023] As discussed in more detail below, the loop buffer circuit 210 is configured to determine whether loop optimization can be performed at run time based on the captured loop, and if so, to perform the loop optimization to improve loop playback performance. The captured loop includes an instruction pipeline I0-I2 for processing instructions 206 for the captured loop at a given time. NSince the loop may contain more instructions 206 than are present in a particular pipeline stage, the processor can use this expanded visibility of more instructions 206 in the loop captured in the loop buffer circuit 210 to determine loop optimizations for the loop. These loop optimizations are implemented by the instruction pipelines I0-I1. N In some cases, the loop may not be able to be otherwise determined at compile time and / or run time based solely on knowledge of the presence of a particular instruction 206 of the loop in the captured loop. In this regard, if the loop buffer circuit 210 determines whether loop optimization can be performed based on the captured loop, the loop buffer circuit 210 is configured to modify at least one instruction 206 in the captured loop to generate an optimized loop. The optimized loop is an optimization loop in which the loop is optimized by modifying at least one instruction 206 in the instruction pipeline I0-I1 in each iteration. N When reprocessing and reexecuting within the instruction pipeline I0 to I N 2, loop optimization can be achieved by processor 200. To achieve loop optimization, loop buffer circuit 210 advances instruction pipelines I0-I1 in one of a number of stages, including rename / allocate circuit 222 (e.g., instruction reclaiming), instruction fetch circuit 212 (e.g., to control / pause fetching of new instructions 206 during reclaiming), and issue circuit 230 (to provide scheduling hints for scheduling the issuance of reclaimed instructions 206D). N The optimization loop is configured to regenerate the optimization loop injected into the

[0024] FIG. 3 is a diagram of an example loop buffer circuit 300 that may be provided as loop buffer circuit 210 of FIG. 2. An example operation of loop buffer circuit 300 of FIG. 3 will be described in conjunction with an example process 400 of FIG. 4 for detecting and capturing loops and implementing loop optimization of the captured loops to optimize processing efficiency during playback. Loop buffer circuit 300 will be described with reference to processor 200 of FIG. 2. In this regard, as shown in FIG. 3, this example loop buffer circuit 300 includes a loop detection circuit 302. Loop detection circuit 302 detects and captures instruction pipelines I0-I1, I2, I3, I4, I5, I6, I7, I8, I9, I10, I11, I12, I13, I14, I15, I16, I17, I18, I19, I22, I23, I24, I25, I26, I27, I28, I29, I30, I31, I32, I33, I34, I35, I36, I37, I38, I39, I40, I41, I42, I43, I44, I45, I46, I47, I48, I49, I50, I51, I52, I53, I54, I55, I56, I57, I58, I59, I60, I61, I62, I63, I64, I65, I66, I70, I71, I72, I73, I74, I75, I76, I77, I78, I79, I80, I81, I82, I83, I84, I85, I85, I86, I87, I88, I89, I90, I91, I92, I93,N , and is configured to receive a copy or instance of the decoded instruction 206D, in this example, within the instruction stream 208 of the instruction processing circuit 204. The loop detection circuit 302 is coupled to the instruction pipelines I0-I N 2. The loop detection circuit 302 is configured to detect whether a loop exists in the decoded instructions 206D in the instruction stream 208 in the instruction pipeline 100 (block 402 in FIG. 4). If a loop exists, the loop includes multiple loop instructions 206D in the decoded instructions 206D. For example, the loop detection circuit 302 detects the instruction pipeline I0-I1 after being decoded by the instruction decode circuit 220 (FIG. 2). N The instruction pipeline I0 to I1 may include an instruction buffer circuit 304 configured to store the decoded instructions 206D flowing through the instruction pipeline I0 to I2. The loop detection circuit 302 may reference the stored instructions 206D to determine whether a subsequent younger instruction 206D repeats the captured instruction 206D. N The stored instruction 206D detected by the loop detection circuit 302 as repeating sequentially at is considered a captured loop.

[0025] In response to the loop detection circuit 302 detecting the loop of stored instructions 206D in the instruction stream 208 as a loop (block 404 of FIG. 4), the loop detection circuit 302 is configured to communicate the stored instructions 206D of the loop as a captured loop 308 to the loop capture circuit 306. The loop capture circuit 306 captures the detected loop instructions 206D for the captured loop 308 among the "X" instruction entries 310(1)-310(X) in the loop buffer memory 312 (block 406 of FIG. 4). In this manner, the loop capture circuit 306 has a record and an instance of the instructions 206D of the captured loop 308. It should be noted that the loop buffer memory 312 can be provided as part of the loop capture circuit 306 and / or the loop buffer circuit 300, by way of example, or as a separate memory circuit within the processor 202 of FIG. 2.

[0026] Continuing with reference to FIG. 3, the loop buffer circuit 300 of this example further includes a loop optimization circuit 318. As described in more detail below in a number of examples, the loop optimization circuit 318 is configured to determine whether loop optimization can be performed on the captured loop 308 based on the captured loop 308 captured by the loop capture circuit 306 (block 408 of FIG. 4). The loop optimization circuit 318 may be configured to incrementally analyze the instruction 206D as the instruction 206D is captured by the loop capture circuit 306 or once the loop capture circuit 306 has completely captured the captured loop 308. In response to the loop optimization circuit 318 determining that loop optimization can be performed on the captured loop 308, the loop optimization circuit 318 is configured to modify the captured loop 308 in the loop buffer memory 312 of the loop capture circuit 306 to generate an optimized loop 308O (block 410 of FIG. 4). The optimized loop 308O is a modification of the instructions 206D in the captured loop 308 that are replayed to replay the captured loop 308 and / or a modification of the way the captured loop 308 is processed by the instruction processing circuit 204 during replay, which may result in more efficient processing of the captured loop 308 during replay. This may increase the throughput of the replay of the captured loop 308 in the instruction processing circuit 204. The loop replay circuit 314 is configured to replay the optimized loop 308O of the captured loop 308 based on the modifications of the captured loop 308 by the loop optimization circuit 318.

[0027] For example, as described in more detail below, the loop optimization circuit 318 can perform certain loop optimizations based on the captured loop 308 that reduce the number of instructions 206D that need to be replayed within the captured loop 308, while still achieving the same functionality of the captured loop 308 when processed with a replay of the captured loop 308 in the instruction processing circuit 204. Also, as described in more detail below, the loop optimization circuit 318 can perform other loop optimizations based on the captured loop 308 that reduce the number of clock cycles required to process and execute a replay of the captured loop 308 in the instruction processing circuit 204, as compared to the number of clock cycles required to execute a replay of the original captured instructions 206D of the captured loop 308 having the same functionality. Also, as described in more detail below, the loop optimization circuit 318 can perform other loop optimizations based on the captured loop 308 that provide critical instructions, such as timing critical instructions (e.g., loads or instructions that are unlocking instructions to unlock dependent flow paths, indicated by scheduling hints to be scheduled for execution at a higher priority when replayed in the instruction processing circuit 204). In this manner, such critical instructions can be executed sooner and the results they produce can be ready before being consumed by other consumer instructions in the replayed captured loop 308. This can increase the throughput of replaying the captured loop 308 in the instruction processing circuit 204.

[0028] Additionally, as described in more detail below, loop optimization circuitry 318 may perform further loop optimizations based on captured loop 308 that may identify instructions that are load / store operations that may be separated from captured loop 308 as instruction execution slices. An instruction execution slice within the captured loop is instruction set 206D within captured loop 308 that calculates load / store memory addresses required for memory load / store instructions executed upon replay of captured loop 308. Loop optimization circuitry 318 may be configured to convert the extracted instruction execution slices identified from captured loop 308 into software prefetch instructions that are then loaded into instruction pipelines I0-I1 when captured loop 308 is replayed to perform the loop optimizations of the captured loop. N By processing the software prefetch instruction for the instruction execution slice, the instruction processing circuit 204 injects the extracted instruction 206D in the instruction execution slice as a prefetch instruction 206 into the instruction pipelines I0 to I1. N Thus, cache misses resulting from memory operations performed by treating the extracted execution slice instructions as prefetch instructions 206 can be recovered sooner to be consumed by dependent instructions in the captured loop 308 when the captured loop is replayed.

[0029] Continuing to refer to FIG. 3, the loop capture circuit 306 transfers the instruction 206D of the captured loop 308 to the instruction pipeline I0-I1 of the instruction processing circuit 204. N 4. The loop replay circuit 314 is configured to provide instructions 206D of the captured loop 308 or the optimization loop 308O to a loop replay circuit 314 to be replayed within the captured loop 308 (i.e., processed again in another iteration of the loop). The loop replay circuit 314 determines whether the captured loop 308 should be replayed (block 412 of FIG. 4). In response to determining that the captured loop 308 should be replayed, the loop replay circuit 314 routes the instructions 206D of the captured loop 308 or the optimization loop 308O to the instruction pipelines I0-I1 to be replayed.N The captured loop 308 can be inserted into the instruction pipeline I0-I1 so that the loop regeneration circuit 314 can regenerate the instruction 206D of the captured loop 308 (block 414 in FIG. 4). N In order to insert N In this example, the loop replay circuit 314 does not need to re-decode the fetched instruction 208F in the detected loop, so it re-encodes the instruction 206D of the captured loop 308 or the optimized loop 308O into the instruction pipeline I0-I1 after the instruction decode circuit 220 in FIG. N In this example, the loop recovery circuit 314 is configured to inject or insert instructions 206D of the captured loop 308 or the optimized loop 308O into the instruction pipeline I0-I1 before the rename / allocate circuit 222 of FIG. 2 because the processor 200 in this example is an out-of-order processor. N Thus, the decoded instructions 206D from the regenerated captured loop 308 or optimized loop 308O may be processed and / or executed out of order according to the issuance of the decoded instructions 206D by the issue circuitry 230.

[0030] In this example, the loop replay circuit 314 is also coupled to the instruction fetch circuit 212 so that when the loop replay circuit 314 replays the loop, it can send a loop replay indicator 316 to the instruction fetch circuit 212. The instruction fetch circuit 212 can cease fetching the instruction 206D of the captured loop 308 while the instruction is being fetched in the instruction pipelines I0-I1 of the instruction processing circuit 204. N It is played (inserted) in.

[0031] As mentioned above, some captured loops 308 may have optimizations available that may be modified by removing or combining instructions 206D of the captured loop 308 to optimize the captured loop 308 into an optimized loop 308O for replay. In this regard, FIG. 5A is a diagram of an exemplary captured loop 308(1) of instructions 500(1)-500(5) captured from the decoded instructions 206D from the instruction processing circuitry 204 of FIG. 2 into respective instruction entries 310(1)-310(5) in the loop buffer memory 312 of FIG. 3. The instructions 500(1)-500(5) are included in the respective instruction entries 310(1)-310(5) of the loop buffer memory 312 in this example. As shown in FIG. 5A, the second instruction 500(2) of the captured loop 308(1) is a compare instruction (“cmp r1,r4”) that compares register r1 with register r4. Compare instruction 502(1) is an instruction that provides a result to a flags register of processor 202. Also shown in FIGURE 5A is fifth instruction 500(5) of captured loop 308(1) a branch if not equal (BNE) instruction that branches back to first instruction 500(1) of captured loop 308(1). The BNE instruction is thus a consumer of the flags register that is set by execution of the old compare operation of second instruction 500(2).

[0032] Loop optimization circuitry 318 of Figure 3 can be configured to detect the presence of flag producer instruction 500(2) in captured loop 308(1) and flag consumer instruction 505(5). Loop optimization circuitry 318 of Figure 3 can detect that instructions 500(2)-504(4) between producer flag instruction 500(1) and consumer flag instruction 500(5) do not modify registers r1 or r4. Thus, in this example, loop optimization circuitry 318 can modify captured loop 308(1) by converting instruction 500(5) of captured loop 308(1) to a compare and branch if not equal (CBNZ) instruction 500M(5), as shown in optimized loop 308O(1) of Figure 5B for captured loop 308(1) of Figure 5A. Thus, loop optimization circuit 318 may also convert second instruction 500(2) as optimized loop 308O(1) of FIG. 5B by removing second instruction 500(2) from instruction entry 310(2) of loop buffer memory 312 for captured loop 308(1) of FIG. 5A, thereby fusing second instruction 500(2) with modified CBNZ instruction 500M(5) of optimized loop 308O(1). In this manner, when captured loop 308(1) of FIG. 5B is replayed as optimized loop 308O(1) of FIG. 5B, one less instruction needs to be replayed among instructions 500(1), 500(3)-504(4), and 500M(5) than would be replayed if captured loop 308(1) of FIG. 5A were replayed. This may result in faster replay of captured loop 308(1).

[0033] FIG. 6 is a flow chart illustrating an example process 600 of the loop buffer circuit 300 of FIG. 2 for implementing the determined loop optimization by capturing the detected loop and converting the instructions in the captured loop 308 into an optimized loop 308O to improve the performance of the playback of the captured loop 308. The process 600 of FIG. 6 can be used by the loop buffer circuit 300 to generate the optimized loop 308O(1) of FIG. 5B based on the captured loop 308(1) of FIG. 5A, as an example. The process 600 of FIG. 6 is described with reference to the loop buffer circuit 300 of FIG. 3 and the instruction processing circuit 204 of FIG. 2. It should be noted that when reference is made to the loop buffer circuit 300 of FIG. 6 with respect to the process 600 of FIG. 6, certain circuits previously referenced in the loop buffer circuit 300 of FIG. 3 may be configured to perform the described process even if they are not explicitly referenced in describing the process 600 of FIG. 6.

[0034] In this regard, process steps 602, 604, 606 are the same as process steps 402, 404, 406 in process 400 of FIG. 4 described above, and therefore are not repeated. As shown in step 408, the loop buffer circuit 300 is configured to determine, based on the captured loop 308, whether the at least one loop instruction 206D of the captured loop 308 can be transformed while maintaining the same functionality as the at least one loop instruction 206D when executed (block 608 of FIG. 6). In response to determining that the at least one loop instruction 206D of the captured loop 308 can be transformed while maintaining the same functionality as the at least one loop instruction 206D when executed, the loop buffer circuit 300 is further configured to transform the at least one loop instruction 206D of the captured loop 308 to generate the optimized loop 308O (block 610 of FIG. 6). Continuing to refer to FIG. 6, the loop buffer circuit 300 transfers the instruction 206D of the captured loop 308 to the instruction pipelines I0-I1 of the instruction processing circuit 204. NThe loop buffer circuit 300 is configured to provide instructions 206D of the captured loop 308 or the optimization loop 308O to a loop replay circuit 314 to be replayed within the loop (i.e., processed again in another iteration of the loop). The loop buffer circuit 300 determines whether the captured loop 308 should be replayed (block 612 of FIG. 6). In response to determining that the captured loop 308 should be replayed, the loop buffer circuit 300 routes the instructions 206D of the captured loop 308 or the optimization loop 308O to the instruction pipelines I0-I1 to be replayed. N (block 614 in FIG. 6).

[0035] It should be noted that the loop buffer circuit 300 can be configured to find producer and consumer pair instructions 206D in the captured loop 308, which can be fused in the optimized loop 308O to provide loop optimization. It should also be noted that the loop buffer circuit 300 can be configured to find producer and consumer pair instructions 206D that occur between different iterations of the captured loop 308 during replay. For example, the same instruction 206D in the captured loop 308 can be both a producer and a consumer instruction. Such an instruction 206D is its own producer instruction as a consumer instruction in a subsequent iteration of the replay of the captured loop 308. Thus, the loop buffer circuit 300 can be configured to identify an instruction 206D in the captured loop 308, which can be fused with itself to generate the optimized loop 308O for replay.

[0036] FIG. 7A is a diagram of another example captured loop 308(2) of instructions 700(1)-700(6) captured from decoded instructions 206D from instruction processing circuit 204 of FIG. 2 into respective instruction entries 310(1)-310(6) in loop buffer memory 312 of FIG. 3. Here, another transformation optimization that provides a reduction in instruction strength may be detected by loop buffer circuit 300 at run-time. As shown in FIG. 7A, a fourth instruction 700(4) in instruction entry 310(4) in loop buffer memory 312 of captured loop 308(2) is a multiplication instruction of a value contained in register r2 and a value contained in register r5, with the result stored back in register r2 ("mult r2, r2, r5"). Loop buffer circuit 300 of FIG. 3 and its loop optimization circuit 318 may be configured to detect that there are no other instructions in captured loop 308(1) that are producers of register "r5." Thus, the value in register r5 when captured loop 308(2) is replayed in a first instance in instruction processing circuit 204 of FIG. 2 remains the same value in subsequent iterations of captured loop 308(2) when replayed. Thus, in this example, loop optimization circuit 318 can be configured to determine whether the value stored in register r5 is a value that allows multiplication instruction 700(4) to be converted to another instruction that requires fewer clock cycles to execute (i.e., less intensity) when replayed. For example, if register r5 contains a value of 4, which is a power of 2. This means that loop optimization circuit 318 can convert and replace multiplication instruction 700(4) in captured loop 308(2) in optimization loop 308O(2) with a move instruction that performs a two-bit left shift of the value in r2, as shown in modified instruction 700M(4) in instruction entry 310(4), to perform a four-times operation on the value in register r2, which is the value in register r5. Thus, move instruction 700M(4) in optimization loop 308O(2) is an alternative instruction that, when executed, has the same functionality as multiply instruction 700(4) in captured loop 308(2) of FIG. 7A, but can execute in fewer clock cycles.In this way, the doubling operation on register r2 is performed in fewer clock cycles when captured loop 308(2) of FIG. 7A is replayed as optimized loop(2) of FIG. 7B, resulting in faster replay of captured loop 308(2).

[0037] It should be noted that there are other examples of instructions 206D within the captured loop 308 that can be converted to less intense instructions to allow the captured loop 308 to be played faster and more efficiently. For example, an instruction 206D within the captured loop 308 that is determined to be a zero-add function can be replaced with a move instruction within the optimized loop 308O.

[0038] As another example, the captured loop 308 may include an instruction 206D that is loop invariant, meaning that the produced value of an execution of such instruction 206D is always the same for any iteration of the replayed loop. For example, such a loop invariant instruction may be an instruction that stores a constant value in a target register, where the target register is not modified by other producer instructions. In this example, to optimize the captured loop 308 with such a loop invariant instruction 206D, the loop optimization circuit 318 of FIG. 3 may remove the loop invariant instruction 206D from the optimization loop 308O such that the loop invariant instruction is not replayed when the captured loop 308 is replayed as the optimization loop 308O. Thus, the value in the target register from the first replay of the captured loop 308 remains constant and the same and does not change during replay of the captured loop 308 as the optimization loop 308O. This allows the captured loop 308 to be replayed with one less instruction, in this example as the optimization loop 308O, for more efficient replay.

[0039] In another exemplary aspect, the loop buffer circuit 300 of FIG. 3 and its loop optimization circuit 318 can be configured to perform a loop post-capture instruction transformation analysis of the instructions 206D in the captured loop 308 to detect critical timing instructions 206D. The loop buffer circuit 300 is configured to transform such identified critical instructions 206D with scheduling hints that are used by a scheduling circuit, such as the issue circuit 230 of FIG. 2, to prioritize issuance for execution by the execution circuit 218 when replayed. For example, the instructions 206D in the captured loop 308 identified as performing a critical load are critical instructions whose timing may affect other dependent instructions in the captured loop 308. The critical instructions 206D can be transformed with scheduling hints such that, upon replay of the captured loop 308, these instructions 206D are scheduled for execution by the instruction processing circuit 204 before other instructions 206D in the captured loop. An example of a critical load instruction 206D in the captured loop 308 is a load instruction in the captured loop 308 whose generated result is consumed by a conditional branch instruction 206D. The generated result of the load instruction 206D is necessary to resolve the prediction of the conditional branch instruction 206D. Thus, in the case of a conditional branch instruction 206D, faster replay and execution of the critical load instruction 206D can result in faster resolution of the mispredicted conditional branch instruction 206D. Another example of a critical instruction 206D in the captured loop 308 that can benefit from a scheduling hint is an instruction 206D that is identified as having a dependency chain in the captured loop 308 and marks such key unlock instruction 206D with a scheduling priority.

[0040] FIG. 8A is a diagram of another exemplary captured loop 308(3) of instructions 800(1)-800(7) captured from decoded instructions 206D from instruction processing circuit 204 of FIG. 2 into respective instruction entries 310(1)-310(7) in loop buffer memory 312 of FIG. 3. Here, another transformation optimization that provides scheduling hints to critical instructions may be detected by loop buffer circuit 300 at run time. As shown in FIG. 8A, a second instruction 800(2) of instruction entry 310(2) in loop buffer memory 312 of captured loop 308(3) is a load instruction that loads a value stored in memory at a memory address in register r1 into register r2. As shown in FIG. 8A, a sixth instruction 800(6) of instruction entry 310(6) in loop buffer memory 312 of captured loop 308(3) is a compare instruction that compares a value stored in register r2 with zero (0). The next instruction 800(7) is a branch if not equal (BNE) instruction, which is a conditional branch instruction based on a comparison of register r2 to 0 (zero) in instruction 800(6). Conditional branch instruction 800(7) therefore depends on load instruction 800(2). Load instruction 800(2) must be executed to resolve the value in register r2 before it can be determined whether conditional branch instruction 800(7) was mispredicted. Load instruction 800(2) is therefore a critical timing instruction with respect to conditional branch instruction 800(7). If conditional branch instruction 800(7) is frequently mispredicted, this means that the misprediction will not be discovered until load instruction 800(2) is executed.

[0041] Thus, in this example, loop optimization circuitry 318 may be configured to determine whether load instruction 800(2) is a producer instruction that is a critical timing instruction for consumer conditional branch instruction 800(7). Loop optimization circuitry 318 may be configured to provide a scheduling hint SH to a scheduling priority indicator 802(2) associated with instruction entry 310(2) that includes load instruction 800(2) as optimized loop 308O(3), as shown in FIG. 8B. For example, instruction entries 310(1)-310(7) in loop buffer memory 312 may be added to also include respective scheduling priority indicators 802(1)-802(7), thereby enabling loop optimization circuitry 318 to indicate the scheduling priority of such instructions 800(1)-800(7) to provide the determined optimization of captured loop 308(3) as optimized loop 308O(3). This scheduling hint is accessed by loop replay circuitry 314 of FIG. 3 as optimization loop 308O(3) is replayed and provided to issue circuitry 230 of instruction processing circuitry 204 of FIG. 2 as optimization loop 308O(3) is replayed. Issue circuitry 230 can use the indication of scheduling hint SH of load instruction 800(2) to know to schedule load instruction 800(2) for execution by execution circuitry 218 at a higher priority if possible. In this way, load instruction 800(2) can be resolved sooner to determine sooner whether conditional branch instruction 800(7) was mispredicted. Recovery procedures to recover from a misprediction of conditional branch instruction 800(7) can be executed sooner than other procedures that might be executed if load instruction 800(2) was resolved later.

[0042] As another example, the captured loop 308 may include critical instructions 206D that are critical as unlocking instructions 206D between parallel dependency chains within the captured loop 308. For example, the captured loop 308 may include many independent load instructions 206D or longer-latency instructions 206D that are producer instructions to other consumer instructions. These load instructions 206D or longer-latency instructions 206D that are producer instructions to other consumer instructions are known as critical "unlocking" instructions. Thus, these unlocking instructions 206D are prioritized to be executed earlier in the playback of the captured loop 308, and additional performance may be realized because other consumer instructions can be issued earlier by the issue circuitry 230 of FIG. 2 because their operands are available sooner. In this regard, as described above, the loop optimization circuit 318 can be configured to provide a scheduling hint SH to a scheduling priority indicator associated with an instruction entry 310(1)-310(X) including such a critical unlock instruction 206D of the captured loop 308 to generate the optimized loop 308O. This scheduling hint is accessed by the loop replay circuit 314 of FIG. 3 when the optimized loop 308O is replayed and provided to the issue circuit 230 of the instruction processing circuit 204 of FIG. 2 when the optimized loop 308O is replayed. The issue circuit 230 can use an indication of the scheduling hint SH of the unlock instruction 206D to know to schedule the unlock instruction 206D for execution by the execution circuit 218 at a higher priority if possible. In this way, the unlock instruction 206D can be resolved sooner so that dependent instructions can be scheduled sooner for execution by the issue circuit 230.

[0043] In another exemplary aspect, the loop buffer circuit 300 of FIG. 3 and its loop optimization circuit 318 can be configured to determine loop optimization for the captured loop 308 by performing a post-loop capture instruction analysis of the instructions 206D in the captured loop 308 to identify any instruction execution slices. An instruction execution slice in the captured loop 308 is a set of instructions 206D in the captured loop 308 that calculates the load / store memory addresses required for memory load / store instructions executed in the replay of the captured loop 308. Memory loads and stores in the replayed captured loop 308 that cause cache misses will degrade the performance of the instruction pipeline throughput when the captured loop 308 is replayed. However, memory loads and stores in the replayed captured loop 308 that cause more frequent cache misses may increase the performance degradation of the instruction pipeline throughput as a function of the number of replay iterations of the captured loop 308.

[0044] Thus, as described in more detail below, loop buffer circuit 300 may be configured to extract the identified instruction execution slice identified in instruction 206D of captured loop 308. Loop buffer circuit 300 may be configured to convert the identified extracted instruction execution slice into a software prefetch instruction that is then prefetched into instruction pipelines I0-I1 in processor 200 of FIG. 2 when captured loop 308 is replayed to perform loop optimization of the captured loop. N By processing the software prefetch instruction for the instruction execution slice, the instruction processing circuit 204 of the processor 200 of FIG. 2 injects the extracted instruction 206D in the instruction execution slice into the instruction pipeline I0 to I1 as the prefetch instruction 206. N3. Thus, cache misses resulting from memory operations performed by treating the extracted execution slice instructions as prefetch instructions 206 can be recovered sooner to be consumed by dependent instructions 206D when the captured loop 308 is replayed. The extracted instruction execution slices can be stored, for example, in a separate buffer separate from the loop buffer memory 312 of FIG. 3, or, for example, within the loop buffer memory 312 along with a special identifier (e.g., via additional pointer bits) that is used to generate a software prefetch instruction.

[0045] In this regard, FIG. 9A is a diagram of an exemplary captured loop 308(4) of instructions 900(1)-900(6) captured into respective instruction entries 310(1)-310(6) in loop buffer memory 312 of FIG. 3. Captured loop 308(4) includes an instruction execution slice consisting of instructions 900(1) and 900(3). Instruction 900(1) is an add instruction that adds one to the value stored in register r1 and then stores the result back in register r1. Instruction 900(3) is a load instruction that loads the contents of the memory location in register r1 into register r2. Both instructions 900(1) and 900(3) must be executed to resolve the memory address in register r1 and load that value into register r2. Instructions 900(4) and 900(5) depend on register r2 as a source register, and thus instructions 900(4) and 900(5) depend on the result produced by load instruction 900(3). Thus, the instruction execution slices identifiable from captured loop 308(4) of Figure 9A are add instruction 900(1) and load instruction 900(3). If load instruction 900(3) in captured loop 308(4) results in a cache miss, this will delay the execution of instructions 900(4) and 900(5) during replay.

[0046] Thus, loop optimization circuitry 318 of Figure 3 may be configured to detect instruction execution slices for instructions 900(1) and 900(3) and remove these instructions from captured loop 308(2) upon replay as part of optimization loop 308O(4) shown in Figure 9B. Loop optimization circuitry 318 of Figure 3 may be configured to create software prefetch instructions 206 in a prefetch mode that represents instructions 900(1), 900(3) as a "prefetch slice" or instruction execution slice 902 that is provided to a prefetch stage (e.g., instruction fetch circuitry 212 in instruction processing circuitry 204 of Figure 2) before captured loop 308(4) is replayed. As shown in FIG. 9B, the instruction execution slice 902 in this example is based on instructions 900(1) and 900(3), and both instructions 900(1) and 900(3) must be executed to resolve the memory address of register r1 and load that value into register r2 for dependent instructions 900(4) and 900(5) to execute. As shown in FIG. 9B, the instruction execution slice is the original add instruction 900(1) followed by a modified instruction 900P(3) of instruction 900(3), which is a "prefetch" instruction that prefetches the contents of the memory location at the memory address stored in register r1 (as updated by instruction 900(1)) into register r2. Both instruction 900(1) and instruction 900P(3) are provided as prefetch instructions to the instruction pipeline in the replay of optimization loop 308O(4).

[0047] This is illustrated in an exemplary processor 1000 in a processor-based system 1002 of FIG. 10 that includes an instruction processing circuit 1004. Common components between the processor 1000 of FIG. 10 and the processor 200 of FIG. 2 are indicated with common element numbers and will not be described again. As shown in FIG. 10, a loop buffer circuit 1010 is provided that may be similar to the loop buffer circuit 210 of FIG. 2 and / or the loop buffer circuit 300 of FIG. 3. The loop buffer circuit 1010 may perform any of the functions described above. The loop buffer circuit 1010 may also be configured to provide software prefetch instructions 206 of the instruction execution slice 906 to the instruction fetch circuit 212 to be played ahead as prefetch instructions before other instructions of the captured loop 308(4) in the example of FIG. 10B are played. In this manner, instruction processing circuitry 1004 of Figure 10 may process instructions 900(1), 900P(3) first as instruction execution slice 902 of captured loop 308(4) before instructions 900(4), 900(5) from captured loop 308(4) are replayed, such that results produced from processing instructions 900(1), 900(3) may be made available sooner in the event of a cache miss due to load instruction 900(3). In this regard, instructions 900(1), 900(3), which have been converted to software prefetch instructions 206 in instruction execution slice 902 as described above, and the remaining instructions 900(2) and 900(4)-900(6), constitute the optimization loop of captured loop 308 of Figure 9. The instruction execution slice 902 may be replayed to prefetch data stored at the memory address in register r1 into register r2 and load the data into register r2 for each iteration of the replayed optimization loop 308O(4). Thus, multiple instances of the instruction execution slice 902 are replayed as prefetch instructions for multiple future original loop iterations of the optimization loop 308O(4).

[0048] Note that in one example, instructions 900(1), 900(3) of prefetch slice 902 may be completely removed from loop buffer memory 312 by loop optimization circuit 318 such that the remaining instructions 206 reproduced as normal instructions in optimization loop 308O(4) are instructions 900(2) and 900(4)-900(6). Alternatively, loop optimization circuit 318 may leave instructions 900(1), 900(3) of instruction execution slice 902 in loop buffer memory 312, as shown in FIG. 9B, but provide pointers in pointer fields 904(1)-904(6) provided as part of respective instruction entries 310(1)-310(6) in loop buffer memory 312. Loop optimization circuit 318 may store a pointer value in each pointer field 904(1)-904(6) to indicate whether each instruction 900(1)-900(6) is part of the detected instruction execution slice 902, such that the pointer value stored in pointer field 904(1)-904(6) points to the next instruction 900(1)-900(6) in instruction execution slice 902.

[0049] For example, as shown in FIG. 9B, instruction 900(1) includes a pointer value "3" in each pointer field 904(1) indicating that instruction 900(1) is part of the detected instruction execution slice 902. Instruction 900(3) includes a pointer value "E" in each pointer field 904(3) indicating that it is the last instruction 900(3) as part of the detected instruction execution slice 902. In this manner, loop replay circuit 314 can use these indicators to convert instructions 900(1), 900(3) into software prefetch instructions 206 and provide them to the prefetch stage of instruction processing circuit 1004 for processing before the remaining instructions 900(2), 900(4)-900(6) are replayed. The advantage of storing the instructions of instruction execution slice 902 in loop buffer memory 312 itself is the efficiency of requiring only minimal additional memory bits to indicate the instructions as part of instruction execution slice 902, as opposed to having to provide a side storage structure. This also applies to the instruction pipelines I0 to I1 of the instruction processing circuit 1004 in FIG. N This minimizes the bindings and entry points required for the instruction execution slice 902. The instruction execution slice 902 can be repeatedly replayed using the pointers in the pointer fields 904(1)-904(6).

[0050] Note that the software prefetch instructions 206 of the instruction execution slice 902 are known as non-architectural instructions. This means that the instruction processing circuitry 1004 does not allocate resources for the processing of such instructions, such as a location in the reorder buffer, a committed mapping table, etc. Thus, as a result of processing the instruction execution slice 902 as a prefetch instruction, the instruction pipelines I0-I1 of the instruction processing circuitry 1004 of FIG. NThe work performed in does not update the architectural state of the processor 1000 in this example. Thus, the processing of the instruction execution slice 902 does not affect data from the programmer's perspective. However, the loaded data resulting from the processing of the instruction execution slice 902 is brought into the data cache of the processor 1000. The resources allocated to the instruction execution slice 902 are released in the instruction processing circuitry 1004 as soon as the generated values ​​are consumed by the replay of the optimization loop 308O(4). This is because if any prefetch instruction 206 of the instruction execution slice 902 causes a fault, the prefetch instruction 206 of the instruction execution slice 902 can simply be discarded and does not need to be recovered. The prefetch instruction 206 of the instruction execution slice 902 can be replayed from the optimization loop 308O(4) by the loop buffer circuitry 1010 in a normal replay mode without the need to be generated as a prefetch instruction.

[0051] 11 is a flow chart illustrating an example process 1100 of the loop buffer circuit 1010 of FIG. 10 for capturing a detected loop and detecting an instruction execution slice 906 in the captured loop 308 as an available loop optimization. The loop buffer circuit 1010 performs a loop optimization on the instruction pipelines I0-I1 to realize such a loop optimization when the captured loop 308 is replayed. N 3. The optimization loop 308O generates and injects software prefetch instructions 206 representing instructions in the detected instruction execution slice 906 into the prefetch stage of the instruction execution slice 906 as part of the optimization loop 308O. The process 1100 of FIG. 11 is described with reference to the loop buffer circuit 1010 and the instruction processing circuit 1004 of FIG. 2. It should be noted that where reference is made to the loop buffer circuit 1010 with respect to the process 1100 of FIG. 11, certain circuitry referenced above in the loop buffer circuit 300 of FIG. 3 may be configured to perform the described process even though it is not explicitly referenced in describing the process 1100 of FIG. 11.

[0052] In this regard, process steps 1102, 1104, 1106 are the same as process steps 402, 404, 406 in process 400 of FIG. 4 described above, and therefore are not repeated. The next step of process 1108 of FIG. 11 is for loop buffer circuit 1010 to determine, based on captured loop 308, whether instruction execution slice 906 exists in captured loop 308 (block 1108 of FIG. 11). If instruction execution slice 906 exists in captured loop 308 (block 1108 of FIG. 11), loop buffer circuit 1010 modifies captured loop 308 to generate optimized loop 308O, which includes identifying instruction execution slice 906 in captured loop 308 (block 1110 of FIG. 11). Loop buffer circuit 1010 determines whether captured loop 308 is in instruction pipeline I0-I1. N The loop buffer circuit 1010 determines whether the captured loop 308 should be replayed in the instruction pipeline I0-I1 (block 1112 of FIG. 11). N 11, block 1112, the loop buffer circuit 1010 creates at least one prefetch instruction 206 representing the identified instruction execution slice 906 within the captured loop 308 (block 1114, FIG. 11) and routes the at least one prefetch instruction 206 to the instruction pipelines I0-I1 for execution. N The loop buffer circuit 1010 then inserts the other instructions 206D in the optimization loop 308O that are not identified as an instruction execution slice 906 into the prefetch stage in the instruction pipeline I0-I10 for execution (block 1116 of FIG. 11 ). N (block 1118 of FIG. 11).

[0053] 12 is a block diagram of an exemplary processor-based system 1200 including a processor 1202 (e.g., a microprocessor) that includes an instruction processing circuit 1204 that processes and executes instructions 1205. The processor 1202 and / or the instruction processing circuit 1204 may include a loop buffer circuit 1206 that may be configured to detect and capture loops from the processed instructions 1205 in the instruction processing circuit 1204. The loop buffer circuit 1206 may also be configured to determine whether loop optimization can be performed based on the captured loop to improve performance of the loop playback. If the loop buffer circuit 1206 determines that loop optimization can be performed based on the captured loop, the loop buffer circuit 1206 is configured to perform such loop optimization such that such loop optimization can be realized when playing back the captured loop to improve playback performance of the captured loop. For example, the processor 1202 of Figure 12 may be the processor 200 of Figure 2 including the instruction processing circuit 204 and the loop buffer circuit 210, or the processor 1202 of Figure 12 including the instruction processing circuit 1204 and the loop buffer circuit 1206. The loop buffer circuit 1206 of Figure 12 may be, for example, the loop buffer circuit 210 of Figure 2, the loop buffer circuit 300 of Figure 3, or the loop buffer circuit 1010 of Figure 10.

[0054] The processor-based system 1200 may represent one or more circuits included in an electronic board card such as a printed circuit board (PCB), a server, a personal computer, a desktop computer, a laptop computer, a personal digital assistant (PDA), a computing pad, a mobile device, or any other device, for example, a server or a user's computer. In this example, the processor-based system 1200 includes a processor 1202. The processor 1202 represents one or more processing circuits such as a microprocessor, a central processing unit, or the like. The processor 1202 is configured to execute processing logic in instructions to perform the operations and steps described herein. Instructions fetched or prefetched from a memory such as the system memory 1210 via a system bus 1212 are stored in an instruction cache 1208. The instruction processing circuit 1204 is configured to process instructions 1205 fetched into the instruction cache 1208 and process the instructions for execution. These instructions 1205 fetched from the instruction cache 1208 to be processed may include loops that are detected by the loop buffer circuit 1206 for playback based on prediction of one or more loop characteristics as loop characteristic predictions.

[0055] The processor 1202 and the system memory 1210 are coupled to a system bus 1212, which may interconnect peripheral devices included in the processor-based system 1200. As is well known, the processor 1202 communicates with these other devices by exchanging address, control, and data information via the system bus 1212. For example, the processor 1202 may communicate bus transaction requests to a memory controller 1214 in the system memory 1210, as an example of a slave device. Instructions 1205 may also be stored in the system memory 1210 and retrieved from the system memory 1210 for execution by the instruction processing circuitry 1204. Although not shown in FIG. 12, multiple system buses 1212 may be provided, with each system bus constituting a different fabric. In this example, the memory controller 1214 is configured to provide memory access requests to a memory array 1216 in the system memory 1210. The memory array 1216 is comprised of an array of storage bit cells for storing data. System memory 1210 may include, by way of non-limiting example, read only memory (ROM), flash memory, dynamic random access memory (DRAM) such as synchronous DRAM (SDRAM), and static memory (e.g., flash memory, static random access memory (SRAM), etc.).

[0056] Other devices may be connected to the system bus 1212. As shown in FIG. 12, these devices may include, by way of example, a system memory 1210, one or more input devices 1218, one or more output devices 1220, a modem 1222, and one or more display controllers 1224. The input devices 1218 may include any type of input device, including but not limited to input keys, switches, voice processors, and the like. The output devices 1220 may include any type of output device, including but not limited to audio, video, other visual indicators, and the like. The modem 1222 may be any device configured to enable data exchange with a network 1226. The network 1226 may be any type of network, including but not limited to a wired or wireless network, a private or public network, a local area network (LAN), a wireless local area network (WLAN), a wide area network (WAN), a BLUETOOTH network, and the Internet. The modem 1222 may be configured to support any type of communication protocol desired. The processor 1202 may also be configured to access a display controller 1224 via the system bus 1212 to control information sent to one or more displays 1228. The display 1228 may include any type of display, including, but not limited to, a cathode ray tube (CRT), a liquid crystal display (LCD), a plasma display, etc.

[0057] The processor-based system 1200 of FIG. 12 may include a set of instructions 1230 that are executed by the instruction processing circuitry 1204 of the processor 1202 for any application desired according to the instructions. The instructions 1230 may include loops that are processed by the instruction processing circuitry 1204. The instructions 1230 may be stored in the system memory 1210, the processor 1202, and / or the instruction cache 1208 as examples of non-transitory computer-readable media 1232. The instructions 1230 may also reside completely or at least partially within the system memory 1210 and / or the processor 1202 during its execution. The instructions 1230 may further be transmitted or received over the network 1226 via the modem 1222, the network 1226 including the non-transitory computer-readable media 1232. The instructions 1230 may also be executed by the processor 1202 to perform the functions of the loop buffer circuitry 1206 to detect and capture loops and perform optimization of the loops for playback.

[0058] Although the non-transitory computer-readable medium 1232 is shown in the exemplary embodiment to be a single medium, the term "computer-readable medium" should be considered to include a single medium or multiple media (e.g., a centralized or distributed database and / or associated caches and servers) that store one or more sets of instructions. The term "computer-readable medium" should also be considered to include any medium that can store, encode or transmit a set of instructions for execution by a processing device, causing the processing device to perform any one or more of the methodologies of the embodiments disclosed herein. Thus, the term "computer-readable medium" is intended to include, but is not limited to, solid-state memories, optical media, and magnetic media.

[0059] The embodiments disclosed herein include various steps. The steps of the embodiments disclosed herein may be formed by hardware components or may be embodied in machine-executable instructions that can be used to program a general-purpose or special-purpose processor with the instructions to perform the steps. Alternatively, the steps may be performed by a combination of hardware and software.

[0060] The embodiments disclosed herein may be provided as a computer program product or software that includes a machine-readable medium (or computer-readable medium) having instructions stored thereon, which can be used to program a computer system (or other electronic device) to perform a process according to the embodiments disclosed herein. A machine-readable medium includes any mechanism for storing or transmitting information in a form readable by a machine (e.g., a computer). For example, machine-readable media include machine-readable storage media (e.g., ROM, random access memory ("RAM"), magnetic disk storage media, optical storage media, flash memory devices, etc.), etc.

[0061] Unless otherwise indicated, and as is apparent from the preceding discussion, throughout the description, discussions using terms such as "processing," "calculating," "determining," "displaying," and the like will be understood to refer to operations and processes of a computer system or similar electronic computing device or other such information storage, transmission, or display device that manipulates and transforms data and memory, represented as physical (electronic) quantities in the computer system's registers, into other data, also represented as physical quantities in the computer system's memory or registers.

[0062] The algorithms and displays presented herein are not inherently related to any particular computer or other apparatus. A variety of systems may be used with programs in accordance with the teachings herein, or it may prove convenient to construct more specialized apparatus to perform the required method steps. The required structure for a variety of these systems is given from the description above. Further, the embodiments described herein are not described with reference to any particular programming language. It will be understood that a variety of programming languages ​​can be used to implement the teachings of the embodiments as described herein.

[0063] Those skilled in the art will further appreciate that the various exemplary logic blocks, modules, circuits, and algorithms described in connection with the embodiments disclosed herein may be implemented as electronic hardware, instructions stored in a memory or another computer-readable medium and executed by a processor or other processing device, or a combination of both. The components of the distributed antenna system described herein may be used in any circuit, hardware component, integrated circuit (IC), or IC chip, as examples. The memory disclosed herein may be any type and size of memory and may be configured to store any type of information desired. To clearly illustrate this interchangeability, various exemplary components, blocks, modules, circuits, and steps have been described above generally in terms of their functionality. How such functionality is implemented depends on the particular application, design choices, and / or design constraints imposed on the overall system. Those skilled in the art may implement the described functionality in different ways for each particular application, but such implementation decisions should not be interpreted as departing from the scope of the present embodiments.

[0064] The various example logic blocks, modules, and circuits described in connection with the embodiments disclosed herein may be implemented or performed using a processor, a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA), or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or any combination thereof, designed to perform the functions described herein. Furthermore, the controller may be a processor. The processor may be a microprocessor, but alternatively, the processor may be any conventional processor, controller, microcontroller, or state machine. The processor may be implemented as a combination of computing devices (e.g., a combination of a DSP and a microprocessor, multiple microprocessors, one or more microprocessors in conjunction with a DSP core, or any other such configuration).

[0065] The embodiments disclosed herein may be implemented in hardware and instructions stored in the hardware, which may reside, for example, in RAM, flash memory, ROM, Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), registers, hard disk, removable disk, CD-ROM, or any other form of computer readable medium known in the art. An exemplary storage medium is coupled to the processor such that the processor can read information from the storage medium and write information to the storage medium. Alternatively, the storage medium may be integrated into the processor. The processor and the storage medium may be located in an ASIC. The ASIC may reside in a remote station. Alternatively, the processor and the storage medium may reside as separate components in a remote station, base station, or server.

[0066] It should also be noted that the operational steps described in any of the exemplary embodiments herein are described to provide examples and discussion. The described operations may be performed in many different sequences other than the sequence illustrated. Furthermore, an operation described in one operational step may actually be performed in many different steps. Furthermore, one or more operational steps described in the exemplary embodiments may be combined. Those skilled in the art will also appreciate that information and signals may be represented using any of a variety of technologies and techniques. For example, data, instructions, commands, information, signals, bits, symbols, and chips may be referenced throughout the above description and may be represented by voltages, currents, electromagnetic waves, magnetic fields, or particles, optical fields or particles, or any combination thereof.

[0067] Unless otherwise expressly stated, the methods described herein are in no way intended to be construed as requiring that its steps be performed in a particular order. Thus, unless a method claim actually recites the order in which its steps should be followed, or unless the claim or description specifically states that the steps are limited to a particular order, no particular order is intended to be inferred.

[0068] It will be apparent to those skilled in the art that various modifications and variations can be made without departing from the spirit or scope of the present invention. Since modifications, combinations, subcombinations and variations of the disclosed embodiments incorporating the spirit and content of the present invention may occur to those skilled in the art, the present invention should be construed as including all within the scope of the appended claims and their equivalents.

Claims

1. 1. A processor comprising: an instruction processing circuit configured to process an instruction stream including a plurality of instructions in an instruction pipeline; 1. A loop buffer circuit, comprising: detecting a loop including a plurality of loop instructions among the plurality of instructions in the instruction stream; in response to detecting the loop in the instruction stream, capturing the plurality of loop instructions of the detected loop as a captured loop; determining whether loop optimization can be performed on the captured loop based on the captured loop; In response to determining that the loop optimization can be performed on the captured loop, modifying the captured loop to generate an optimized loop; determining whether the captured loop is to be replayed in the instruction pipeline; responsive to determining that the captured loop is to be replayed in the instruction pipeline, inserting the optimized loop into the instruction pipeline to be replayed; a loop buffer circuit configured to A processor including

2. The loop buffer circuit includes: determining whether at least one loop instruction of the plurality of loop instructions within the captured loop can be transformed while maintaining the same functionality as the at least one loop instruction when executed; in response to determining that at least one loop instruction of the plurality of loop instructions in the captured loop can be transformed while maintaining the same functionality as the at least one loop instruction when executed, transforming the at least one loop instruction of the plurality of loop instructions in the captured loop to generate the optimized loop.

2. The processor of claim 1, configured to determine whether the loop optimization can be performed on the captured loop based on the captured loop.

3. The loop buffer circuit includes: determining whether at least two loop instructions of the plurality of loop instructions in the captured loop can be fused into at least one fused instruction that has the same function as the at least two loop instructions when executed; determining whether the at least one loop instruction of the plurality of loop instructions in the captured loop can be transformed; in response to determining that the at least two loop instructions of the plurality of loop instructions can be fused into the at least one fused instruction that has a same function as the at least two loop instructions when executed, fusing the at least two loop instructions of the plurality of loop instructions in the captured loop to generate the optimized loop. The processor of claim 2 configured to:

4. The loop buffer circuit includes: determining whether at least one loop instruction of the plurality of loop instructions in the captured loop can be transformed by determining whether at least one loop instruction of the plurality of loop instructions in the captured loop can be fused with itself in the captured loop when the captured loop is executed in at least one subsequent iteration of the captured loop; identifying that the at least one loop instruction of the plurality of loop instructions in the captured loop will not be replayed in at least one subsequent iteration of execution of the captured loop in response to determining that the at least one loop instruction of the plurality of loop instructions in the captured loop can be fused with itself in the captured loop when the captured loop is executed in at least one subsequent iteration of execution of the captured loop, thereby generating the optimized loop. The processor of claim 2 configured to:

5. The loop buffer circuit includes: determining whether the at least one loop instruction of the plurality of loop instructions within the captured loop is loop invariant with respect to the captured loop, thereby determining whether the at least one loop instruction of the plurality of loop instructions within the captured loop can be transformed; in response to determining that the at least one loop instruction of the plurality of loop instructions in the captured loop is loop invariant with respect to the captured loop, removing from the captured loop the at least one loop instruction of the plurality of loop instructions that has been determined to be loop invariant to generate the optimized loop. The processor of claim 2 configured to:

6. The loop buffer circuit includes: determining whether the at least one loop instruction of the plurality of loop instructions in the captured loop can be changed to at least one alternative instruction having the same function as the at least one loop instruction and can be executed in fewer clock cycles than the at least one loop instruction; in response to determining that the at least one loop instruction of the plurality of loop instructions in the captured loop is changed to at least one alternative instruction having a same function as the at least one loop instruction and capable of executing in fewer clock cycles than the at least one loop instruction, converting the at least one loop instruction of the plurality of loop instructions in the captured loop to the at least one alternative instruction to generate the optimized loop. The processor of claim 2 configured to:

7. The loop buffer circuit includes: determining whether the at least one loop instruction of the plurality of loop instructions in the captured loop is a critical instruction, thereby determining whether the at least one loop instruction of the plurality of loop instructions in the captured loop can be converted; in response to determining that the at least one loop instruction of the plurality of loop instructions in the captured loop is a critical instruction, setting a scheduling priority indicator associated with the critical instruction such that the critical instruction is scheduled for execution in the instruction pipeline at a higher priority when the optimized loop is inserted into the instruction pipeline for reproduction as the optimized loop. The processor of claim 2 configured to:

8. 8. The processor of claim 7, wherein the loop buffer circuit is configured to determine whether the at least one loop instruction of the plurality of loop instructions in the captured loop is a critical load instruction, thereby determining whether the at least one loop instruction of the plurality of loop instructions in the captured loop is a critical instruction.

9. 8. The processor of claim 7, wherein the loop buffer circuitry is configured to determine whether the at least one loop instruction of the plurality of loop instructions in the captured loop is an unlock instruction, thereby determining whether the at least one loop instruction of the plurality of loop instructions in the captured loop is a critical instruction.

10. The loop buffer circuit includes: determining whether an instruction execution slice exists among the plurality of loop instructions within the captured loop, thereby determining whether the loop optimization can be performed on the captured loop based on the captured loop; configured to identify the instruction execution slice from among the plurality of loop instructions in the captured loop in response to determining that the instruction execution slice is among the plurality of loop instructions in the captured loop, thereby generating the optimized loop; in response to determining that the captured loop should be replayed within the instruction pipeline, generating at least one prefetch instruction representing the identified instruction execution slice within the captured loop; inserting said at least one prefetch instruction into a prefetch stage within said instruction pipeline for execution; inserting other instructions within the optimized loop that are not identified as an instruction execution slice into the instruction pipeline for execution; thereby inserting the optimization loop into the instruction pipeline in a regenerative manner. The processor of claim 1 configured to:

11. The loop buffer circuit includes: determining whether the captured loop should be played back in a normal playback mode within the instruction pipeline; responsive to determining that the captured loop should be replayed in a normal replay mode within the instruction pipeline, inserting the optimized loop into the instruction pipeline to be replayed; The processor of claim 10 further configured to:

12. 11. The processor of claim 10, wherein the instruction processing circuitry is further configured to execute the at least one prefetch instruction inserted into the instruction pipeline as at least one non-architected instruction.

13. 1. A method for regenerating an optimized loop based on a captured loop in an instruction pipeline in a processor, comprising: detecting a loop comprising a plurality of loop instructions among a plurality of instructions in an instruction stream comprising a plurality of instructions in an instruction pipeline; in response to detecting a loop in the instruction stream; capturing the loop instructions of the detected loop as a captured loop; determining, based on the captured loop, whether loop optimization can be performed on the captured loop; modifying the captured loop to generate an optimized loop in response to determining that the loop optimization can be performed on the captured loop; determining whether the captured loop should be replayed within the instruction pipeline; responsive to determining that the captured loop should be replayed within the instruction pipeline, inserting the optimized loop into the instruction pipeline to be replayed; The method includes:

14. determining whether the loop optimization can be performed on the captured loop based on the captured loop, determining whether at least one loop instruction of the plurality of loop instructions in the captured loop can be transformed while maintaining the same functionality as the at least one loop instruction when executed; The step of modifying at least one instruction entry of a plurality of instruction entries in a loop buffer memory of the captured loop to generate the optimized loop includes: in response to determining that the at least one loop instruction of the plurality of loop instructions in the captured loop can be transformed while maintaining the same functionality as the at least one loop instruction when executed, transforming the at least one loop instruction of the plurality of loop instructions in the captured loop to generate the optimized loop. The method of claim 13.

15. determining whether the loop optimization can be performed on the captured loop based on the captured loop, determining whether an instruction execution slice exists among the plurality of loop instructions in the captured loop; The step of modifying the captured loop to generate the optimized loop comprises: identifying the instruction execution slice among the plurality of loop instructions within the captured loop in response to determining that the instruction execution slice exists among the plurality of loop instructions within the captured loop; in response to determining that the captured loop should be replayed within the instruction pipeline, generating at least one prefetch instruction representing the identified instruction execution slice within the captured loop; inserting said at least one prefetch instruction into a prefetch stage within said instruction pipeline for execution; inserting other instructions within the optimized loop that are not identified as an instruction execution slice into the instruction pipeline for execution; 14. The method of claim 13, further comprising inserting the optimization loop into the instruction pipeline to be regenerated by:

Citation Information

Patent Citations

  • Optimization device, optimization method and compiler program

    JP2012053679A

  • Arithmetic processing device and control method of arithmetic processing device

    JP2020077333A

  • Caching optimized internal instructions in loop buffer

    US20130262822A1

  • Method and apparatus for loop-invariant instruction detection and elimination

    US20170185407A1

  • Loop code processor optimizations

    US20170192787A1