US20170060552A1 - Method of splitting register live ranges - Google Patents
Method of splitting register live ranges Download PDFInfo
- Publication number
- US20170060552A1 US20170060552A1 US14/838,457 US201514838457A US2017060552A1 US 20170060552 A1 US20170060552 A1 US 20170060552A1 US 201514838457 A US201514838457 A US 201514838457A US 2017060552 A1 US2017060552 A1 US 2017060552A1
- Authority
- US
- United States
- Prior art keywords
- register
- symbolic
- node
- instructions
- nodes
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 238000000034 method Methods 0.000 title claims abstract description 23
- 230000037361 pathway Effects 0.000 claims abstract description 75
- 238000004590 computer program Methods 0.000 claims abstract description 11
- 238000003860 storage Methods 0.000 claims description 34
- 230000015654 memory Effects 0.000 description 19
- 238000010586 diagram Methods 0.000 description 12
- 230000008901 benefit Effects 0.000 description 9
- 230000002085 persistent effect Effects 0.000 description 8
- 238000012545 processing Methods 0.000 description 8
- 230000006870 function Effects 0.000 description 7
- 230000005540 biological transmission Effects 0.000 description 4
- 230000003287 optical effect Effects 0.000 description 4
- 239000004744 fabric Substances 0.000 description 3
- 238000004458 analytical method Methods 0.000 description 2
- 238000003491 array Methods 0.000 description 2
- 230000001902 propagating effect Effects 0.000 description 2
- 239000004065 semiconductor Substances 0.000 description 2
- 210000003813 thumb Anatomy 0.000 description 2
- RYGMFSIKBFXOCR-UHFFFAOYSA-N Copper Chemical compound [Cu] RYGMFSIKBFXOCR-UHFFFAOYSA-N 0.000 description 1
- 229910052802 copper Inorganic materials 0.000 description 1
- 239000010949 copper Substances 0.000 description 1
- 230000001419 dependent effect Effects 0.000 description 1
- 238000009826 distribution Methods 0.000 description 1
- 239000000835 fiber Substances 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 230000007246 mechanism Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000002093 peripheral effect Effects 0.000 description 1
- 230000008569 process Effects 0.000 description 1
- 239000007787 solid Substances 0.000 description 1
- 230000003068 static effect Effects 0.000 description 1
- 238000012546 transfer Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
- G06F8/44—Encoding
- G06F8/443—Optimisation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
- G06F8/44—Encoding
- G06F8/441—Register allocation; Assignment of physical memory space to logical memory space
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
- G06F8/44—Encoding
- G06F8/443—Optimisation
- G06F8/4434—Reducing the memory space required by the program code
- G06F8/4435—Detection or removal of dead or redundant code
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/30—Arrangements for executing machine instructions, e.g. instruction decode
- G06F9/30098—Register arrangements
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/30—Arrangements for executing machine instructions, e.g. instruction decode
- G06F9/38—Concurrent instruction execution, e.g. pipeline or look ahead
- G06F9/3836—Instruction issuing, e.g. dynamic instruction scheduling or out of order instruction execution
- G06F9/3838—Dependency mechanisms, e.g. register scoreboarding
- G06F9/384—Register renaming
Definitions
- the present invention relates generally to software compilers, and more specifically, to register allocation.
- Hardware registers store bits of information and are often tightly coupled to CPUs and referenced in software instructions.
- Hardware registers are physical entities, and as such a system is provided with a finite number of hardware registers.
- Symbolic registers are virtual registers located in memory, and thus may be potentially limitless in number.
- Register assignment occurs when symbolic registers are assigned to the hardware registers on a system.
- One problem area in register assignment occurs when a program's demand for symbolic registers exceeds the number of hardware registers available.
- a method, executed by a computer, for splitting live register ranges includes identifying one or more H pathways comprising one or more H nodes having high register pressure, identifying an L pathway consisting of two or more L nodes, and inserting a register move for each symbolic register that is live in both the one or more H pathways and the L pathway, wherein the register move is inserted at a starting node of the one or more H pathways.
- a computer program product and computer system corresponding to the above method are also disclosed herein.
- FIG. 1 is a flowchart depicting one embodiment of a register range splitting method in accordance with the present invention
- FIG. 2 depicts an example of one embodiment of a depth-first search in accordance with the present invention
- FIG. 3 depicts an example of one embodiment of a reduced control-flow graph in accordance with the present invention.
- FIG. 4 is a block diagram depicting one example of a computing apparatus (i.e., computer) suitable for executing the methods disclosed herein.
- a computing apparatus i.e., computer
- Embodiments of the present invention relate generally to software compilers, and in particular, to register allocation.
- Register assignment occurs when symbolic registers are assigned to the hardware registers on a computing system.
- a program may require a certain number of symbolic registers in order to complete an operation, but this number surpasses the number of hardware registers currently available for allocation. When this happens, it is necessary to spill the symbolic registers that have been assigned to hardware registers but are not currently being used in the operation. Spilling these unused symbolic registers may then free up hardware registers for the software registers that are being used.
- the instructions to spill symbolic registers are referred to as spill code, and may be placed in sub-optimal locations within a program's code. Since spilling a symbolic register represents a memory operation, reducing the number of spill operations may prove to be a means of optimizing a program. Embodiments of the present invention may address this issue by splitting the ranges in which a register is live, so that the same register is no longer used in both high and low register pressure regions.
- references throughout this specification to features, advantages, or similar language herein do not imply that all of the features and advantages that may be realized with the embodiments disclosed herein should be, or are in, any single embodiment of the invention. Rather, language referring to the features and advantages is understood to mean that a specific feature, advantage, or characteristic described in connection with an embodiment is included in at least one embodiment of the present invention. Thus, discussion of the features, advantages, and similar language, throughout this specification may, but do not necessarily, refer to the same embodiment.
- FIG. 1 is a flowchart depicting one embodiment of a register range splitting method 100 in accordance with the present invention.
- the register range splitting method 100 includes identifying ( 110 ) H pathways, identifying ( 120 ) L pathways, inserting ( 130 ) register splitting instructions, and inserting ( 140 ) register merging instructions.
- the register range splitting method 100 splits the original range of a symbolic register r into two ranges: one range for register r that has low register pressure, and one range for the new symbolic register r′, which has high register pressure. Splitting the live ranges of registers in this manner may ensure that no spill code will need to be executed when following a path with low register pressure.
- Identifying ( 110 ) H pathways may include identifying one or more pathways in a program that have high register pressure.
- a program can be represented as a reduced control-flow graph, which is a series of nodes connected to each other. In a reduced control-flow graph, all of the sub-loops of a portion of code may be reduced to a single entity known as a basic block or a node.
- a pathway may thus be defined as a sequence of nodes.
- a pathway may run the length of a program if it begins at the program's entry node and ends at the exit node.
- An H pathway is a pathway in which some or all of the nodes have high register pressure.
- register pressure is considered high for a node when the amount of symbolic registers used by the node exceed the number of hardware registers physically present in the processor executing the program.
- register pressure may be tracked separately for each register type.
- a backwards data flow may be performed on the control-flow graph.
- symbolic registers may be identified as live at the end of each node in which the registers are used. Since this is a backwards data flow, a symbolic register may be flagged as dead once it is first defined, as it cannot exist in code prior to its definition. Whenever the number of live symbolic registers exceeds the number of hardware registers at a node, that node may be denoted as having high register pressure, and may be referred to as an H node.
- the number of live registers at a node is compared to the maximum number of live registers found so far in the analysis, and if that number exceeds the maximum, then the maximum is updated to reflect this new number of live registers.
- a pathway may thus be determined to be an H pathway if it contains any H nodes.
- L pathways may include performing an analysis over the entire code of a program to discover pathways having low register pressure.
- An L pathway may be defined as a pathway of nodes in which every node is an L node, meaning that it has low register pressure.
- an H pathway may contain either all H nodes or a combination of H and L nodes, an L pathway in contrast may be strictly limited to being a series of L nodes.
- L pathways are identified using a simple depth first search, as described in greater detail with regard to FIG. 2 .
- Inserting ( 130 ) register splitting instructions may include creating for each symbolic register r a new symbolic register, r′, that will be used in an H pathway wherever r would normally be used.
- the register move from r to r′ may occur when an r′ is created, the information that is stored in r is stored in r′, and references to r are replaced by r′ in the H pathway.
- the live range for the symbolic register r is split: r may be live only in the L pathways, and r′ may be live in the H pathways. Splitting the live range of r may optimize the compiled program because r will no longer have to be spilled after use in each L node.
- the register move from r to r′ may be inserted at the first node in the H pathway. In other embodiments, the register move from r to r′ may be inserted in the last node that is immediately before the H pathway.
- Inserting ( 140 ) register merging instructions may include merging the symbolic register r′ back to r after an H pathway.
- the register merge from r′ to r occurs at the last node belonging to an H pathway.
- the register move may occur at the first node immediately after the H pathway.
- FIG. 2 depicts an example 200 of one embodiment of a depth-first search in accordance with the present invention.
- the example 200 includes an entry node, an exit node, and eight nodes labeled A through H.
- the arrows between each node may be referred to as edges and represent the flow of execution of the program represented by example 200 .
- the entire program may be systematically analyzed on a node-by-node basis by performing a depth-first search.
- a depth-first search may start at the entry node and proceed as far down a pathway as possible until it reaches the exit node, at which point the depth-first search reverses direction until it arrives at a branching point and follows the next pathway down.
- a depth-first search has a left-edge preference, meaning that when it arrives at a branch, it will proceed down the leftmost direction before returning to the branch and working its way to the right.
- a depth-first search may have a right-edge preference.
- the depth-first search may determine whether the node has high or low register pressure.
- the depth-first search would proceed to A, then D, then F, and then the exit node, whereupon the depth-first search would back up to B. From B, the search would reach the exit node and then back up to B again. Finally, the depth-first search would proceed to C, then E, then G and the exit node, backing up to E, and then proceeding to H and the exit node, at which point the search is finished.
- the sequence is A-D-F-B-C-E-G-H.
- the order would be C-E-H-G-B-A-D-F.
- a depth-first search may be used to systematically search every node in order to discover a sequence of L nodes and thus label the sequence as an L pathway.
- the depth-first search runs as a post-order search that starts at the exit node.
- the order in which the nodes may be processed in a post-order depth-first search is F-D-A-B-G-H-E-C, or, with the other handedness preference, H-G-E-C-B-F-D-A.
- FIG. 3 depicts an example 300 of one embodiment of a reduced control-flow graph in accordance with the present invention.
- the example 300 includes L pathway 310 , H pathway 320 , an entry node/basic block bb 1 , an exit node/basic block bb 10 , and intermediate nodes bb 2 -bb 9 .
- L pathway 310 contains L nodes bb 1 , bb 2 , and bb 10 .
- H pathway 320 contains nodes bb 3 through bb 9 (at least one of these nodes is an H node).
- a symbolic register r is defined at bb 1 , and used in bb 2 , bb 5 , and bb 10 .
- the live range of r has been split in this example 300 as follows: symbolic register r is used in the nodes of the L pathway 310 , and symbolic register r′ is used in the H pathway 320 .
- r′ is converted back to r by adding a reverse register move at bb 9 at the end of H pathway 320 .
- spill code may still be required for r′ at bb 5 , as r′ is live from bb 3 to bb 9 and some or all of these nodes may be H nodes.
- FIG. 4 is a block diagram depicting components of a computer 400 suitable for executing the methods disclosed herein. It should be appreciated that FIG. 4 provides only an illustration of one embodiment and does not imply any limitations with regard to the environments in which different embodiments may be implemented. Many modifications to the depicted environment may be made.
- the computer 400 includes communications fabric 402 , which provides communications between computer processor(s) 404 , memory 406 , persistent storage 408 , communications unit 412 , and input/output (I/O) interface(s) 414 .
- Communications fabric 402 can be implemented with any architecture designed for passing data and/or control information between processors (such as microprocessors, communications and network processors, etc.), system memory, peripheral devices, and any other hardware components within a system.
- processors such as microprocessors, communications and network processors, etc.
- Communications fabric 402 can be implemented with one or more buses.
- Memory 406 and persistent storage 408 are computer readable storage media.
- memory 406 includes random access memory (RAM) 416 and cache memory 418 .
- RAM random access memory
- cache memory 418 In general, memory 406 can include any suitable volatile or non-volatile computer readable storage media.
- One or more programs may be stored in persistent storage 408 for execution by one or more of the respective computer processors 404 via one or more memories of memory 406 .
- the persistent storage 408 may be a magnetic hard disk drive, a solid state hard drive, a semiconductor storage device, read-only memory (ROM), erasable programmable read-only memory (EPROM), flash memory, or any other computer readable storage media that is capable of storing program instructions or digital information.
- the media used by persistent storage 408 may also be removable.
- a removable hard drive may be used for persistent storage 408 .
- Other examples include optical and magnetic disks, thumb drives, and smart cards that are inserted into a drive for transfer onto another computer readable storage medium that is also part of persistent storage 408 .
- Communications unit 412 in these examples, provides for communications with other data processing systems or devices.
- communications unit 412 includes one or more network interface cards.
- Communications unit 412 may provide communications through the use of either or both physical and wireless communications links.
- I/O interface(s) 414 allows for input and output of data with other devices that may be connected to computer 400 .
- I/O interface 414 may provide a connection to external devices 420 such as a keyboard, keypad, a touch screen, and/or some other suitable input device.
- external devices 420 can also include portable computer readable storage media such as, for example, thumb drives, portable optical or magnetic disks, and memory cards.
- I/O interface(s) 414 may also connect to a display 422 .
- Display 422 provides a mechanism to display data to a user and may be, for example, a computer monitor.
- the embodiments disclosed herein include a system, a method, and/or a computer program product.
- the computer program product may include a computer readable storage medium (or media) having computer readable program instructions thereon for causing a processor to carry out the methods disclosed herein.
- the computer readable storage medium can be a tangible device that can retain and store instructions for use by an instruction execution device.
- the computer readable storage medium may be, for example, but is not limited to, an electronic storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing.
- a non-exhaustive list of more specific examples of the computer readable storage medium includes the following: a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), a static random access memory (SRAM), a portable compact disc read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanically encoded device such as punch-cards or raised structures in a groove having instructions recorded thereon, and any suitable combination of the foregoing.
- RAM random access memory
- ROM read-only memory
- EPROM or Flash memory erasable programmable read-only memory
- SRAM static random access memory
- CD-ROM compact disc read-only memory
- DVD digital versatile disk
- memory stick a floppy disk
- a mechanically encoded device such as punch-cards or raised structures in a groove having instructions recorded thereon
- a computer readable storage medium is not to be construed as being transitory signals per se, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through a waveguide or other transmission media (e.g., light pulses passing through a fiber-optic cable), or electrical signals transmitted through a wire.
- Computer readable program instructions described herein can be downloaded to respective computing/processing devices from a computer readable storage medium or to an external computer or external storage device via a network, for example, the Internet, a local area network, a wide area network and/or a wireless network.
- the network may comprise copper transmission cables, optical transmission fibers, wireless transmission, routers, firewalls, switches, gateway computers and/or edge servers.
- a network adapter card or network interface in each computing/processing device receives computer readable program instructions from the network and forwards the computer readable program instructions for storage in a computer readable storage medium within the respective computing/processing device.
- Computer readable program instructions for carrying out operations of the present invention may be assembler instructions, instruction-set-architecture (ISA) instructions, machine instructions, machine dependent instructions, microcode, firmware instructions, state-setting data, or either source code or object code written in any combination of one or more programming languages, including an object oriented programming language such as Smalltalk, C++ or the like, and conventional procedural programming languages, such as the “C” programming language or similar programming languages.
- the computer readable program instructions may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server.
- the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet Service Provider).
- electronic circuitry including, for example, programmable logic circuitry, field-programmable gate arrays (FPGA), or programmable logic arrays (PLA) may execute the computer readable program instructions by utilizing state information of the computer readable program instructions to personalize the electronic circuitry, in order to perform aspects of the present invention.
- These computer readable program instructions may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions/acts specified in the flowchart and/or block diagram block or blocks.
- These computer readable program instructions may also be stored in a computer readable storage medium that can direct a computer, a programmable data processing apparatus, and/or other devices to function in a particular manner, such that the computer readable storage medium having instructions stored therein comprises an article of manufacture including instructions which implement aspects of the function/act specified in the flowchart and/or block diagram block or blocks.
- the computer readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device to cause a series of operational steps to be performed on the computer, other programmable apparatus or other device to produce a computer implemented process, such that the instructions which execute on the computer, other programmable apparatus, or other device implement the functions/acts specified in the flowchart and/or block diagram block or blocks.
- each block in the flowchart or block diagrams may represent a module, segment, or portion of instructions, which comprises one or more executable instructions for implementing the specified logical function(s).
- the functions noted in the block may occur out of the order noted in the figures.
- two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Devices For Executing Special Programs (AREA)
- Stored Programmes (AREA)
Abstract
Description
- The following disclosure(s) are submitted under 35 U.S.C. 102(b)(1)(A) as prior disclosures by, or on behalf of, a sole inventor of the present application or a joint inventor of the present application:
-
- (1) IBM XL C/C++ for Linux, V13.1.1 adds an additional compiler for little endian Linux distributions, IBM, Oct. 6, 2014, http://www-01.ibm.com/common/ssi/cgi-bin/ssialias?infotype=an&subtype=ca&appname=gpateam&supplier=877&letternum=ENUSZP14-0521.
- The present invention relates generally to software compilers, and more specifically, to register allocation.
- Two types of registers that are relevant to the field of software compiling are hardware registers and symbolic registers. Hardware registers store bits of information and are often tightly coupled to CPUs and referenced in software instructions. Hardware registers are physical entities, and as such a system is provided with a finite number of hardware registers. Symbolic registers, on the other hand, are virtual registers located in memory, and thus may be potentially limitless in number. Register assignment occurs when symbolic registers are assigned to the hardware registers on a system. One problem area in register assignment occurs when a program's demand for symbolic registers exceeds the number of hardware registers available.
- As disclosed herein, a method, executed by a computer, for splitting live register ranges includes identifying one or more H pathways comprising one or more H nodes having high register pressure, identifying an L pathway consisting of two or more L nodes, and inserting a register move for each symbolic register that is live in both the one or more H pathways and the L pathway, wherein the register move is inserted at a starting node of the one or more H pathways. A computer program product and computer system corresponding to the above method are also disclosed herein.
-
FIG. 1 is a flowchart depicting one embodiment of a register range splitting method in accordance with the present invention; -
FIG. 2 depicts an example of one embodiment of a depth-first search in accordance with the present invention; -
FIG. 3 depicts an example of one embodiment of a reduced control-flow graph in accordance with the present invention; and -
FIG. 4 is a block diagram depicting one example of a computing apparatus (i.e., computer) suitable for executing the methods disclosed herein. - Embodiments of the present invention relate generally to software compilers, and in particular, to register allocation. Register assignment occurs when symbolic registers are assigned to the hardware registers on a computing system. Sometimes a program may require a certain number of symbolic registers in order to complete an operation, but this number surpasses the number of hardware registers currently available for allocation. When this happens, it is necessary to spill the symbolic registers that have been assigned to hardware registers but are not currently being used in the operation. Spilling these unused symbolic registers may then free up hardware registers for the software registers that are being used.
- When an area of code has a demand for symbolic registers that exceeds the number of hardware registers, that area of code may be said to have high register pressure; likewise, when an area of code has enough hardware registers available to it, that area of code has low register pressure. When a symbolic register is used in several high register pressure regions, the symbolic register may need to be spilled between each use. On the other hand, when a symbolic register is used in several low register pressure regions, the symbolic register does not necessarily need to be spilled between each use. In the case that a symbolic register is used in several locations that include both high and low register pressure regions, the fact that even one region has high register pressure “overrides” the low register regions, necessitating the symbolic register to be spilled between each use.
- Conventionally, the instructions to spill symbolic registers are referred to as spill code, and may be placed in sub-optimal locations within a program's code. Since spilling a symbolic register represents a memory operation, reducing the number of spill operations may prove to be a means of optimizing a program. Embodiments of the present invention may address this issue by splitting the ranges in which a register is live, so that the same register is no longer used in both high and low register pressure regions.
- It should be noted that references throughout this specification to features, advantages, or similar language herein do not imply that all of the features and advantages that may be realized with the embodiments disclosed herein should be, or are in, any single embodiment of the invention. Rather, language referring to the features and advantages is understood to mean that a specific feature, advantage, or characteristic described in connection with an embodiment is included in at least one embodiment of the present invention. Thus, discussion of the features, advantages, and similar language, throughout this specification may, but do not necessarily, refer to the same embodiment.
- Furthermore, the described features, advantages, and characteristics of the invention may be combined in any suitable manner in one or more embodiments. One skilled in the relevant art will recognize that the invention may be practiced without one or more of the specific features or advantages of a particular embodiment. In other instances, additional features and advantages may be recognized in certain embodiments that may not be present in all embodiments of the invention.
- These features and advantages will become more fully apparent from the following drawings, description and appended claims, or may be learned by the practice of the invention as set forth hereinafter. The present invention will now be described in detail with reference to the figures.
-
FIG. 1 is a flowchart depicting one embodiment of a registerrange splitting method 100 in accordance with the present invention. As depicted, the registerrange splitting method 100 includes identifying (110) H pathways, identifying (120) L pathways, inserting (130) register splitting instructions, and inserting (140) register merging instructions. The registerrange splitting method 100 splits the original range of a symbolic register r into two ranges: one range for register r that has low register pressure, and one range for the new symbolic register r′, which has high register pressure. Splitting the live ranges of registers in this manner may ensure that no spill code will need to be executed when following a path with low register pressure. - Identifying (110) H pathways may include identifying one or more pathways in a program that have high register pressure. A program can be represented as a reduced control-flow graph, which is a series of nodes connected to each other. In a reduced control-flow graph, all of the sub-loops of a portion of code may be reduced to a single entity known as a basic block or a node. A pathway may thus be defined as a sequence of nodes. A pathway may run the length of a program if it begins at the program's entry node and ends at the exit node.
- An H pathway is a pathway in which some or all of the nodes have high register pressure. In some embodiments, register pressure is considered high for a node when the amount of symbolic registers used by the node exceed the number of hardware registers physically present in the processor executing the program. When there are disjoined register types, such as general purpose registers and float point registers, register pressure may be tracked separately for each register type.
- To identify an H pathway, first a backwards data flow may be performed on the control-flow graph. Working backwards on the graph, symbolic registers may be identified as live at the end of each node in which the registers are used. Since this is a backwards data flow, a symbolic register may be flagged as dead once it is first defined, as it cannot exist in code prior to its definition. Whenever the number of live symbolic registers exceeds the number of hardware registers at a node, that node may be denoted as having high register pressure, and may be referred to as an H node. In some embodiments, the number of live registers at a node is compared to the maximum number of live registers found so far in the analysis, and if that number exceeds the maximum, then the maximum is updated to reflect this new number of live registers. A pathway may thus be determined to be an H pathway if it contains any H nodes.
- Identifying (120) L pathways may include performing an analysis over the entire code of a program to discover pathways having low register pressure. An L pathway may be defined as a pathway of nodes in which every node is an L node, meaning that it has low register pressure. Thus, while an H pathway may contain either all H nodes or a combination of H and L nodes, an L pathway in contrast may be strictly limited to being a series of L nodes. In some embodiments, L pathways are identified using a simple depth first search, as described in greater detail with regard to
FIG. 2 . - Inserting (130) register splitting instructions may include creating for each symbolic register r a new symbolic register, r′, that will be used in an H pathway wherever r would normally be used. The register move from r to r′ may occur when an r′ is created, the information that is stored in r is stored in r′, and references to r are replaced by r′ in the H pathway. Thus, at compilation the live range for the symbolic register r is split: r may be live only in the L pathways, and r′ may be live in the H pathways. Splitting the live range of r may optimize the compiled program because r will no longer have to be spilled after use in each L node. In some embodiments, the register move from r to r′ may be inserted at the first node in the H pathway. In other embodiments, the register move from r to r′ may be inserted in the last node that is immediately before the H pathway.
- Inserting (140) register merging instructions may include merging the symbolic register r′ back to r after an H pathway. In some embodiments, the register merge from r′ to r occurs at the last node belonging to an H pathway. In other embodiments, the register move may occur at the first node immediately after the H pathway.
-
FIG. 2 depicts an example 200 of one embodiment of a depth-first search in accordance with the present invention. As depicted, the example 200 includes an entry node, an exit node, and eight nodes labeled A through H. The arrows between each node may be referred to as edges and represent the flow of execution of the program represented by example 200. The entire program may be systematically analyzed on a node-by-node basis by performing a depth-first search. - A depth-first search may start at the entry node and proceed as far down a pathway as possible until it reaches the exit node, at which point the depth-first search reverses direction until it arrives at a branching point and follows the next pathway down. In some embodiments, a depth-first search has a left-edge preference, meaning that when it arrives at a branch, it will proceed down the leftmost direction before returning to the branch and working its way to the right. Alternatively, in other embodiments a depth-first search may have a right-edge preference. At every node, the depth-first search may determine whether the node has high or low register pressure.
- Assuming a left-edge preference, in this example 200 the depth-first search would proceed to A, then D, then F, and then the exit node, whereupon the depth-first search would back up to B. From B, the search would reach the exit node and then back up to B again. Finally, the depth-first search would proceed to C, then E, then G and the exit node, backing up to E, and then proceeding to H and the exit node, at which point the search is finished. In this example, the sequence is A-D-F-B-C-E-G-H. Assuming instead that the depth-first search has a right-edge preference, the order would be C-E-H-G-B-A-D-F. Thus, a depth-first search may be used to systematically search every node in order to discover a sequence of L nodes and thus label the sequence as an L pathway.
- In another embodiment, the depth-first search runs as a post-order search that starts at the exit node. The order in which the nodes may be processed in a post-order depth-first search is F-D-A-B-G-H-E-C, or, with the other handedness preference, H-G-E-C-B-F-D-A.
-
FIG. 3 depicts an example 300 of one embodiment of a reduced control-flow graph in accordance with the present invention. As depicted, the example 300 includesL pathway 310,H pathway 320, an entry node/basic block bb1, an exit node/basic block bb10, and intermediate nodes bb2-bb9.L pathway 310 contains L nodes bb1, bb2, and bb10.H pathway 320 contains nodes bb3 through bb9 (at least one of these nodes is an H node). In this example 300, a symbolic register r is defined at bb1, and used in bb2, bb5, and bb10. - By applying register
range splitting method 100, the live range of r has been split in this example 300 as follows: symbolic register r is used in the nodes of theL pathway 310, and symbolic register r′ is used in theH pathway 320. Thus, where a program's code originally used r at bb5, it instead will use r′. In some embodiments, r′ is converted back to r by adding a reverse register move at bb9 at the end ofH pathway 320. Thus, now that the live range of r is split, there may no longer be a need to provide spill code for r at bb1, bb2, and/or bb10. In the depicted example, spill code may still be required for r′ at bb5, as r′ is live from bb3 to bb9 and some or all of these nodes may be H nodes. -
FIG. 4 is a block diagram depicting components of acomputer 400 suitable for executing the methods disclosed herein. It should be appreciated thatFIG. 4 provides only an illustration of one embodiment and does not imply any limitations with regard to the environments in which different embodiments may be implemented. Many modifications to the depicted environment may be made. - As depicted, the
computer 400 includescommunications fabric 402, which provides communications between computer processor(s) 404,memory 406,persistent storage 408,communications unit 412, and input/output (I/O) interface(s) 414.Communications fabric 402 can be implemented with any architecture designed for passing data and/or control information between processors (such as microprocessors, communications and network processors, etc.), system memory, peripheral devices, and any other hardware components within a system. For example,communications fabric 402 can be implemented with one or more buses. -
Memory 406 andpersistent storage 408 are computer readable storage media. In the depicted embodiment,memory 406 includes random access memory (RAM) 416 andcache memory 418. In general,memory 406 can include any suitable volatile or non-volatile computer readable storage media. - One or more programs may be stored in
persistent storage 408 for execution by one or more of therespective computer processors 404 via one or more memories ofmemory 406. Thepersistent storage 408 may be a magnetic hard disk drive, a solid state hard drive, a semiconductor storage device, read-only memory (ROM), erasable programmable read-only memory (EPROM), flash memory, or any other computer readable storage media that is capable of storing program instructions or digital information. - The media used by
persistent storage 408 may also be removable. For example, a removable hard drive may be used forpersistent storage 408. Other examples include optical and magnetic disks, thumb drives, and smart cards that are inserted into a drive for transfer onto another computer readable storage medium that is also part ofpersistent storage 408. -
Communications unit 412, in these examples, provides for communications with other data processing systems or devices. In these examples,communications unit 412 includes one or more network interface cards.Communications unit 412 may provide communications through the use of either or both physical and wireless communications links. - I/O interface(s) 414 allows for input and output of data with other devices that may be connected to
computer 400. For example, I/O interface 414 may provide a connection toexternal devices 420 such as a keyboard, keypad, a touch screen, and/or some other suitable input device.External devices 420 can also include portable computer readable storage media such as, for example, thumb drives, portable optical or magnetic disks, and memory cards. - Software and data used to practice embodiments of the present invention can be stored on such portable computer readable storage media and can be loaded onto
persistent storage 408 via I/O interface(s) 414. I/O interface(s) 414 may also connect to adisplay 422.Display 422 provides a mechanism to display data to a user and may be, for example, a computer monitor. - The programs described herein are identified based upon the application for which they are implemented in a specific embodiment of the invention. However, it should be appreciated that any particular program nomenclature herein is used merely for convenience, and thus the invention should not be limited to use solely in any specific application identified and/or implied by such nomenclature.
- The embodiments disclosed herein include a system, a method, and/or a computer program product. The computer program product may include a computer readable storage medium (or media) having computer readable program instructions thereon for causing a processor to carry out the methods disclosed herein.
- The computer readable storage medium can be a tangible device that can retain and store instructions for use by an instruction execution device. The computer readable storage medium may be, for example, but is not limited to, an electronic storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. A non-exhaustive list of more specific examples of the computer readable storage medium includes the following: a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), a static random access memory (SRAM), a portable compact disc read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanically encoded device such as punch-cards or raised structures in a groove having instructions recorded thereon, and any suitable combination of the foregoing. A computer readable storage medium, as used herein, is not to be construed as being transitory signals per se, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through a waveguide or other transmission media (e.g., light pulses passing through a fiber-optic cable), or electrical signals transmitted through a wire.
- Computer readable program instructions described herein can be downloaded to respective computing/processing devices from a computer readable storage medium or to an external computer or external storage device via a network, for example, the Internet, a local area network, a wide area network and/or a wireless network. The network may comprise copper transmission cables, optical transmission fibers, wireless transmission, routers, firewalls, switches, gateway computers and/or edge servers. A network adapter card or network interface in each computing/processing device receives computer readable program instructions from the network and forwards the computer readable program instructions for storage in a computer readable storage medium within the respective computing/processing device.
- Computer readable program instructions for carrying out operations of the present invention may be assembler instructions, instruction-set-architecture (ISA) instructions, machine instructions, machine dependent instructions, microcode, firmware instructions, state-setting data, or either source code or object code written in any combination of one or more programming languages, including an object oriented programming language such as Smalltalk, C++ or the like, and conventional procedural programming languages, such as the “C” programming language or similar programming languages. The computer readable program instructions may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet Service Provider). In some embodiments, electronic circuitry including, for example, programmable logic circuitry, field-programmable gate arrays (FPGA), or programmable logic arrays (PLA) may execute the computer readable program instructions by utilizing state information of the computer readable program instructions to personalize the electronic circuitry, in order to perform aspects of the present invention.
- Aspects of the present invention are described herein with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and/or block diagrams, and combinations of blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer readable program instructions.
- These computer readable program instructions may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions/acts specified in the flowchart and/or block diagram block or blocks. These computer readable program instructions may also be stored in a computer readable storage medium that can direct a computer, a programmable data processing apparatus, and/or other devices to function in a particular manner, such that the computer readable storage medium having instructions stored therein comprises an article of manufacture including instructions which implement aspects of the function/act specified in the flowchart and/or block diagram block or blocks.
- The computer readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device to cause a series of operational steps to be performed on the computer, other programmable apparatus or other device to produce a computer implemented process, such that the instructions which execute on the computer, other programmable apparatus, or other device implement the functions/acts specified in the flowchart and/or block diagram block or blocks.
- The flowcharts and block diagrams in the Figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of instructions, which comprises one or more executable instructions for implementing the specified logical function(s). In some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems that perform the specified functions or acts or carry out combinations of special purpose hardware and computer instructions.
Claims (17)
Priority Applications (3)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
US14/838,457 US9582255B1 (en) | 2015-08-28 | 2015-08-28 | Method of splitting register live ranges |
US14/970,572 US9411565B1 (en) | 2015-08-28 | 2015-12-16 | Method of splitting register live ranges |
US15/163,759 US9483274B1 (en) | 2015-08-28 | 2016-05-25 | Method of splitting register live ranges |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
US14/838,457 US9582255B1 (en) | 2015-08-28 | 2015-08-28 | Method of splitting register live ranges |
Related Child Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
US14/970,572 Continuation US9411565B1 (en) | 2015-08-28 | 2015-12-16 | Method of splitting register live ranges |
Publications (2)
Publication Number | Publication Date |
---|---|
US9582255B1 US9582255B1 (en) | 2017-02-28 |
US20170060552A1 true US20170060552A1 (en) | 2017-03-02 |
Family
ID=56556338
Family Applications (3)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
US14/838,457 Expired - Fee Related US9582255B1 (en) | 2015-08-28 | 2015-08-28 | Method of splitting register live ranges |
US14/970,572 Expired - Fee Related US9411565B1 (en) | 2015-08-28 | 2015-12-16 | Method of splitting register live ranges |
US15/163,759 Expired - Fee Related US9483274B1 (en) | 2015-08-28 | 2016-05-25 | Method of splitting register live ranges |
Family Applications After (2)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
US14/970,572 Expired - Fee Related US9411565B1 (en) | 2015-08-28 | 2015-12-16 | Method of splitting register live ranges |
US15/163,759 Expired - Fee Related US9483274B1 (en) | 2015-08-28 | 2016-05-25 | Method of splitting register live ranges |
Country Status (1)
Country | Link |
---|---|
US (3) | US9582255B1 (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US11593080B1 (en) | 2021-12-17 | 2023-02-28 | International Business Machines Corporation | Eliminating dead stores |
Families Citing this family (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US10956359B2 (en) * | 2017-08-16 | 2021-03-23 | Intel Corporation | Smart performance of spill fill data transfers in computing environments |
EP3872663B1 (en) * | 2020-02-28 | 2024-05-08 | BlackBerry Limited | Method and device for symbolic analysis of a software program |
US11210071B2 (en) * | 2020-04-01 | 2021-12-28 | Microsoft Technology Licensing, Llc | Compiler sub expression directed acyclic graph (DAG) remat for register pressure |
US11645076B2 (en) * | 2021-07-26 | 2023-05-09 | International Business Machines Corporation | Register pressure target function splitting |
Family Cites Families (21)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US4571678A (en) | 1982-11-05 | 1986-02-18 | International Business Machines Corporation | Register allocation and spilling via graph coloring |
US5418958A (en) * | 1992-07-15 | 1995-05-23 | Sun Microsystems, Inc. | Register allocation by decomposing, re-connecting and coloring hierarchical program regions |
US5418959A (en) | 1992-11-30 | 1995-05-23 | Intel Corporation | Instruction operation size optimization |
US5659754A (en) | 1995-03-31 | 1997-08-19 | Sun Microsystems, Inc. | Method and apparatus for an improved optimizing compiler |
US5774730A (en) | 1995-07-31 | 1998-06-30 | International Business Machines Corporation | Method and apparatus for improving colorability of constrained nodes in an interference graph within a computer system |
US5946491A (en) * | 1996-06-06 | 1999-08-31 | International Business Machines Corporation | Register allocation method and apparatus for gernerating spill code as a function of register pressure compared to dual thresholds |
CA2205797C (en) * | 1997-05-22 | 2001-04-24 | Andrew Wilfred Macleod | A system for local context spilling for graph colouring register allocators |
US6427234B1 (en) | 1998-06-11 | 2002-07-30 | University Of Washington | System and method for performing selective dynamic compilation using run-time information |
US6523173B1 (en) | 2000-01-11 | 2003-02-18 | International Business Machines Corporation | Method and apparatus for allocating registers during code compilation using different spill strategies to evaluate spill cost |
JP3651774B2 (en) | 2000-09-12 | 2005-05-25 | インターナショナル・ビジネス・マシーンズ・コーポレーション | Compiler and its register allocation method |
US7543284B2 (en) | 2003-04-22 | 2009-06-02 | Transitive Limited | Partial dead code elimination optimizations for program code conversion |
US20070038984A1 (en) * | 2005-08-12 | 2007-02-15 | Gschwind Michael K | Methods for generating code for an architecture encoding an extended register specification |
US8555270B2 (en) | 2006-04-28 | 2013-10-08 | International Business Machines Corporation | Profile-based global live-range splitting |
JP5165969B2 (en) | 2007-08-29 | 2013-03-21 | インターナショナル・ビジネス・マシーンズ・コーポレーション | Technology for allocating registers to variables for program compilation |
US20100199270A1 (en) | 2009-01-30 | 2010-08-05 | Ivan Baev | System, method, and computer-program product for scalable region-based register allocation in compilers |
US8516465B2 (en) * | 2009-12-04 | 2013-08-20 | Oracle America, Inc. | Register prespill phase in a compiler |
US8555035B1 (en) | 2010-07-07 | 2013-10-08 | Nvidia Corporation | Conflict-free register allocation using a multi-bank register file with input operand alignment |
US8832671B1 (en) * | 2010-07-07 | 2014-09-09 | Nvidia Corporation | Conflict-free register allocation |
US8640112B2 (en) * | 2011-03-30 | 2014-01-28 | National Instruments Corporation | Vectorizing combinations of program operations |
US9229717B2 (en) | 2012-12-11 | 2016-01-05 | Nvidia Corporation | Register allocation for clustered multi-level register files |
US9329867B2 (en) * | 2014-01-08 | 2016-05-03 | Qualcomm Incorporated | Register allocation for vectors |
-
2015
- 2015-08-28 US US14/838,457 patent/US9582255B1/en not_active Expired - Fee Related
- 2015-12-16 US US14/970,572 patent/US9411565B1/en not_active Expired - Fee Related
-
2016
- 2016-05-25 US US15/163,759 patent/US9483274B1/en not_active Expired - Fee Related
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US11593080B1 (en) | 2021-12-17 | 2023-02-28 | International Business Machines Corporation | Eliminating dead stores |
Also Published As
Publication number | Publication date |
---|---|
US9582255B1 (en) | 2017-02-28 |
US9483274B1 (en) | 2016-11-01 |
US9411565B1 (en) | 2016-08-09 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US9483274B1 (en) | Method of splitting register live ranges | |
US10296311B2 (en) | Finding uninitialized variables outside the local scope | |
US9594559B2 (en) | Binary file for computer program having multiple executable code variants for a function that are executable on a same processor architecture | |
US10325844B2 (en) | Modifying execution flow in save-to-return code scenarios | |
US10289391B2 (en) | Optimization of software symbol tables | |
US10599406B2 (en) | Generating executable files through compiler optimization | |
US9405516B2 (en) | Recursive expression simplification | |
US10120666B2 (en) | Conditional branch instruction compaction for regional code size reduction | |
US10425299B2 (en) | Quantifying and designing optimal connecting networks | |
US11886848B2 (en) | Binary translation using raw binary code with compiler produced metadata | |
US11068246B2 (en) | Control flow graph analysis | |
US10360137B2 (en) | Adaptive testing using dynamically determined system resources of a computer system | |
US9720664B2 (en) | Method for defining alias sets | |
GB2527567A (en) | Optimising software code | |
US9697018B2 (en) | Synthesizing inputs to preserve functionality | |
US9553784B2 (en) | Selection of message passing collectives in presence of system noise | |
US9785422B1 (en) | Applying multiple rewriting without collision for semi-automatic program rewriting system | |
US9250870B2 (en) | Automated creation of shim programs and interfaces | |
US11620132B2 (en) | Reusing an operand received from a first-in-first-out (FIFO) buffer according to an operand specifier value specified in a predefined field of an instruction | |
US10891300B2 (en) | Syntactical transformation of database interaction statements |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
AS | Assignment |
Owner name: INTERNATIONAL BUSINESS MACHINES CORPORATION, NEW Y Free format text: ASSIGNMENT OF ASSIGNORS INTEREST;ASSIGNOR:PERRON, STEVEN J.;REEL/FRAME:036445/0131 Effective date: 20150827 |
|
STCF | Information on status: patent grant |
Free format text: PATENTED CASE |
|
FEPP | Fee payment procedure |
Free format text: MAINTENANCE FEE REMINDER MAILED (ORIGINAL EVENT CODE: REM.); ENTITY STATUS OF PATENT OWNER: LARGE ENTITY |
|
LAPS | Lapse for failure to pay maintenance fees |
Free format text: PATENT EXPIRED FOR FAILURE TO PAY MAINTENANCE FEES (ORIGINAL EVENT CODE: EXP.); ENTITY STATUS OF PATENT OWNER: LARGE ENTITY |
|
STCH | Information on status: patent discontinuation |
Free format text: PATENT EXPIRED DUE TO NONPAYMENT OF MAINTENANCE FEES UNDER 37 CFR 1.362 |
|
FP | Lapsed due to failure to pay maintenance fee |
Effective date: 20210228 |