Abstract:
A technique for predicating a speculative load miss based on a predicate value generated before a branch. More particularly, embodiments of the invention pertain to providing a hint to a processor as to whether a speculative load miss should be serviced, based upon a predicate value.

Description:
FIELD  
         [0001]    Embodiments of the invention relate to the field of microprocessor architecture. More particularly, embodiments of the invention relate to predicating load misses in a computer architecture.  
         BACKGROUND  
         [0002]    Load instruction latency can significantly contribute to microprocessor performance degredation. For example, if load instructions do not retreive intended data in a first level cache, thereby causing a “load cache miss”, the load instruction may be issued to other memory sources in the computer system memory hierarchy having greater access latency than the first level cache. In order to help alleviate the effects of load cache misses, modern compilers typically attempt to schedule load instructions in the program as early as possible.  
           [0003]    Techniques, such as inserting loads before a branch instruction within the program can, however, be problematic for some microarchitectures because of possible program faults being generated by the load inserted before the branch. In some microprocessor instruction sets, such as the Intel® IA-64 instruction set, however, it is possible for the compiler to move loads before branches in conjunction with setting special bits, such as a “not a thing” (“NAT”) bit, within various registers of the microarchitecture. Bits, such as NAT bits, may be used by load instructions, such as a speculative load (“Id.s”), to better control program flow in the case of a fault condition caused by performing a load inserted prior to a branch.  
           [0004]    In particular, the Intel® 64 bit architecture allows loads to be replaced by Id.s instructions, which can appear before earlier branches in program order. If execution of the Id.s instruction generates a fault, the NAT bit may be set in the load destination register and read to control the flow of program execution.  
           [0005]    If, however, control flow of the program does not encounter the original site of the load instruction, then the load instruction may be wasted. Furthermore, if execution of the speculative load generates a cache miss, and therefore the load must be serviced by accessing other memory sources within the computer system memory hierarchy, then the cache line fetched by a load miss operation may eject a useful cache line from the cache, further reducing performance.  
           [0006]    Prior art predication techniques have been used to mitigate delay caused by mispredicted branches, and, more particularly, to lessen the performance degredation caused by servicing speculative load misses that are later found not to be useful to the processor.  
           [0007]    One prior art predication technique is illustrated in FIG. 1. The predication technique of FIG. 1 has been “if-converted” by replacing “if” statements in the source code with predicated branches. Particularly, the technique illustrated in FIG. 1 moves a speculative load instruction before a branch label in program order. In order to determine whether the speculative load instruction is to be executed, a predicate is associated with the speculative load instruction. If the predicate is equal to a first value, the speculative load is executed, if the predicate is equal to a second value, the speculative load is not executed.  
           [0008]    The predicate value can be determined by preempting typical “if” statements in source code or branch operations in machine language with compare operations, which typically require fewer processor cycles than an “if” statement.  
           [0009]    Microprocessor architectures, such as those based upon Intel® 64-bit microarchitecture, may take advantage of instruction predication due, at least in part, to the architecture&#39;s ability to conditionally execute instructions based upon a predicate value. In predication techniques, branch operations (in machine code) and “if” statements (in source code) are typically replaced by a compare instruction to assign the value of one or more predicates.  
           [0010]    The predication technique illustrated in FIG. 1, however, is somewhat restrictive in that the decision of whether to perform a speculative load must be determined before the branch is taken or predicted to be taken. Therefore, in the event that the speculative load is a miss, the processor will continue to service the speculative load by accessing main memory to retreive the data.  
           [0011]    In summary, significant delays in microprocessor performance may result from a predicated speculative load miss if subsequent computations within a code thread no longer require the data targeted by the corresponding predicated speculative load. This is due to the fact that a memory controller will typically service the speculative load miss by retrieving the data from another memory source, such as main memory, if the data is not available in cache. Furthermore, if the data is subsequently found not to be necessary (‘useless data’), the delay incurred in retrieving the data is wasted and the retrieved data may in fact result in processor state faults or exceptions.  
       
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS  
       [0012]    Embodiments and the invention are illustrated by way of example and not limitation in the figures of the accompanying drawings, in which like references indicate similar elements and in which:  
         [0013]    [0013]FIG. 1 illustrates a prior art technique for predicating speculative load instructions.  
         [0014]    [0014]FIG. 2 illustrates a technique according to one embodiment of the invention for predicating speculative load misses.  
         [0015]    [0015]FIG. 3 illustrates a processor architecture according to one embodiment of the invention.  
         [0016]    [0016]FIG. 4 illustrates a computer system in which one embodiment of the invention may be implemented.  
         [0017]    [0017]FIG. 5 is a flow diagram illustrating a method for carrying out one embodiment of the invention.  
     
    
     DETAILED DESCRIPTION  
       [0018]    Embodiments of the invention described herein relate to microprocessor architecture, and more specifically, microprocessor instruction predication relating to speculative load miss handling.  
         [0019]    One aspect of embodiments of the invention helps reduce loading of useless data resulting from servicing a speculative load miss by using a predicate to provide the processor and instructions executed by the processor a ‘hint’ as to whether it is likely the speculative load miss data will indeed be useful to subsequent instructions in program order.  
         [0020]    [0020]FIG. 2 illustrates a code segment according to one embodiment of the invention, in which a fetch predicate is used in conjunction with a speculative load placed before a branch label in program order. The speculative load instruction may be an existing speculative load instruction with a fetch predicate included within the instruction or a new instruction, such as Id.sf as illustrated in FIG. 2.  
         [0021]    Regardless, the fetch predicate, P 1 , allows load miss traffic to be disregarded by the processor and subsequent instructions if the predicate value indicates that the speculative load miss data will be useless. Alternatively, the fetch predicate may be a value that indicates to the processor and subsequent instructions that the speculative load miss data will be useful, and the miss may then be serviced by the memory controller to retrieve the load data from memory.  
         [0022]    For example, if the predicate evaluates as “false”, the memory system may not service any misses generated by the speculative load instruction containing the fetch predicate, or the memory system may cancel the servicing of the misses after miss servicing has initiated. If, however, the predicate evaluates as “true”, the program has supplied a hint that miss servicing should be allowed for the corresponding speculative load. In either case, the fetch predicate value may be incorrect in some instances, and program correctness, therefore, may not accurately depend upon the fetch predicate. Fetch predicates can evaluate incorrectly, for example, if read out of program order or if they are generated using partial information.  
         [0023]    The fetch predicate may be a bit or group of bits encoded into a speculative load instruction, and subsequently decoded by the processor before or while the speculative load instruction is being executed. Advantageously, the fetch predicate may be read at any time after fetching and decoding the speculative load instruction in which it is contained, including after the speculative load instruction has executed. Because the fetch predicate is a hint of whether the speculative load data will be useful, other computations may be performed prior to choosing whether to continue with servicing the speculative load miss or canceling it. The fetch predicate hint, therefore, allows greater flexibility in the implementation of using the fetch predicate by postponing the decision of whether to continue or cancel the speculative load miss handling.  
         [0024]    For one embodiment of the invention, the speculative load instruction containing the fetch predicate is itself predicated, whereas in other embodiments it may not be.  
         [0025]    [0025]FIG. 3 illustrates a portion of a microprocessor architecture that may be used to perform at least a portion of one embodiment of the invention. Instructions, after being fetched, are decoded by the decoder  301  before they are sent to the rename unit  305 . The decoder contains logic  307  to decode a fetch predicate included in the speculative load instruction or other load instruction. In the rename unit, the source and destination registers required by the individual micro-operations (“uops”) of the instructions are assigned. Uops may then be passed to the scheduler  310 ,  315  where they are scheduled for execution by the execution unit  320 ,  325 . The parallel execution units are used to execute the branches of a pending branch code segment in parallel in order to resolve the correct branch to be taken. This prevents delays in evaluating incorrect branches and also allows predicates to be evaluated properly. After uops are executed they may then be retired by the retirement unit  330 .  
         [0026]    [0026]FIG. 4 illustrates a computer system in which at least a portion of one embodiment of the invention may be performed. A processor  405  accesses data from a cache memory  410  and main memory  415 , which comprises a memory system. The memory system is used to service speculative load misses depending upon, at least partially, the fetch predicate value.  
         [0027]    Illustrated within the processor of FIG. 4 is logic  406  for determining whether to continue with or cancel servicing the speculative load miss, depending, at least in part, upon the hint provided by the fetch predicate included in the speculative load instruction or other load instruction. Some or all of the logic  406 , however, may be performed in software, hardware, or a combination of software and hardware.  
         [0028]    Furthermore, embodiments of the invention may be implemented within other devices within the system, such as a separate bus agent, or distributed throughout the system in hardware, software, or some combination thereof. The computer system&#39;s main memory is interfaced through a memory/graphics controller  412 . Furthermore, the main memory may be implemented in various memory sources, such as dynamic random-access memory (“DRAM”). Other memory sources may also be used as the system&#39;s main memory and accessed through an input/output controller  417 . These memory sources include a hard disk drive (“HDD”)  420 , or a memory source  430  located remotely from the computer system containing various storage devices and technologies. The cache memory may be located either within the processor or in close proximity to the processor, such as on the processor&#39;s local bus  407 . The system may include other peripheral devices, including a display device  411 , which may interface to a number of displays, such as flat-panel, television, and cathode-ray tube.  
         [0029]    [0029]FIG. 5 is a flow diagram illustrating a method for performing one embodiment of the invention. Embodiments of the invention, such as the method illustrated in the flow diagram of FIG. 5, may be implemented by using standard complimentary metal-oxide-semiconductor (“CMOS”) logic (hardware) or a set of instructions (software) stored on a machine-readable medium, which when executed by a machine, such as a processor, cause the machine to perform the method illustrated in FIG. 5. Alternatively, some aspects of the embodiment of the invention may be implemented in hardware and others in software.  
         [0030]    Referring to FIG. 5, a source code branch block segment is “if-converted” by replacing the “if” statements to compare operations in order to assign values to predicates to be used in the machine code at operation  501 . Control dependency is predicated by replacing a speculative load instruction (“Id.s”) in the machine code with a new instruction containing a fetch predicate (“Id.sf”) and inserting it before the branch condition at operation  502 , and Id.s is replaced with a load check at operation at operation  503 . Compiling the resulting machine code is completed at operation  504 .  
         [0031]    Although the invention has been described with reference to illustrative embodiments, this description is not intended to be construed in a limiting sense. Various modifications of the illustrative embodiments, as well as other embodiments, which are apparent to persons skilled in the art to which the invention pertains are deemed to lie within the spirit and scope of the invention.