What is Register renaming?
In [[computer engineering]], '''register renaming''' refers to a [[technique]] used to avoid unnecessary serialized execution of program [[Instruction (computer science)|instructions]] because of the reuse of the same [[processor register|registers]] by those instructions. ==Problem definition== Programs are composed of [[Instruction (computer science)|instructions]] which operate on values. The instructions must name these values in order to distinguish them from one another. A typical instruction might say, add X and Y and put the result in Z. In this instruction, X, Y, and Z are the names of storage locations. In order to have a compact instruction encoding, most processor instruction sets have a small set of special locations which can be directly named. For example, the [[x86]] [[instruction set]] architecture has 8 integer registers, x86-64 has 16, many RISCs have 32, and IA-64 has 128. In smaller processors, the names of these locations correspond directly to elements of a [[register file]]. Different instructions may take different amounts of time (e.g., CISC architecture). For instance, a processor may be able to execute hundreds of instructions while a single load from main memory instruction is in progress. Shorter instructions executed while the load is outstanding will finish first, thus the instructions are finishing out of the original program order. [[Out-of-order execution]] has been used in most recent high-performance CPUs to achieve some of their speed gains. Consider this sequence of [[Instruction (computer science)|instructions]] running on an out-of-order CPU: <pre> 1.LOAD R1, LOC MEM[1024] 2.R1 = R1 + 2 3.STORE R1, LOC MEM[1024+8] 4.LOAD R1, LOC MEM[2048] 5.R1 = R1 + 4 6.STORE R1, LOC MEM[2048+8] </pre> Instructions 4, 5, and 6 are independent of instructions 1, 2, and 3, but the processor cannot finish 4 until 3 is done, because 3 would then write the wrong value. How to remove restrictions We can remove this restriction by changing the names of some of the registers, so that