Register merging method and device during life cycle conflict

By recalculating the slave register life cycle of the register, the misjudgment problem of register merging method during life cycle conflicts in the prior art is solved, and the accuracy and program performance of the merge are improved.

CN119883369APending Publication Date: 2025-04-25SHANGHAI ENFLAME INTELLIGENCE TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411971940.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-30
Publication Date
2025-04-25

AI Technical Summary

Technical Problem

The prior art register merging method when dealing with life cycle conflicts has misjudgment, especially in the life cycle defined by the PHI instruction, the survival status of the slave register cannot be accurately judged, resulting in misjudgment when register merging.

Method used

By recalculating the life cycle of the slave register of the register with a life cycle conflict, including the life cycle defined by PHI instructions and non-PHI instructions, and taking into account the survival status of each program point in a comprehensive way, we can accurately judge the life cycle conflict when registers are merged.

Benefits of technology

Improve the accuracy of register merge, avoid register merge failure caused by misjudgment, and ensure the performance optimization effect of the program.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119883369A_ABST
    Figure CN119883369A_ABST
Patent Text Reader

Abstract

The invention provides a register merging method and device during life cycle conflict, and relates to the technical field of compilation optimizing.The method comprises the steps that for a first register and a second register which have the life cycle conflict during merging, the life cycle of a slave register is recalculated, and according to the life cycle, obtained through recalculation, of the slave register, the first register and the second register are merged; and judging whether the corresponding slave registers have life cycle conflicts when the first register and the second register are combined, and if not, finishing the combination of the first main register and the second main register based on the slave registers. By recalculating the life cycles of the slave registers of the first register and the second register with life cycle conflicts and comprehensively considering the life cycles defined by the PHI instruction and the non-PHI instruction, it can be more accurately judged that when the first main register and the second main register are combined, the first main register and the second main register are not combined. Whether life cycle conflicts really exist in the corresponding slave registers or not is judged. According to the method, the register merging accuracy can be greatly improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of compilation optimization, and in particular to a register merging method and device when there is a life cycle conflict. Background Art

[0002] In the compilation and optimization process of a program, register allocation is a basic and important optimization step. Register merging optimization is required before register allocation. Register merging can reduce the number of virtual registers, thereby eliminating copy instructions, which is very helpful for program performance.

[0003] The existing register merging methods in the industry when there is a conflict are limited to certain scenarios. For example, in the LLVM compiler framework, the register merging method when there is a life cycle conflict is: if there is a life cycle conflict, detect the surviving channels of each slave register, and then determine whether the register can be merged based on whether the channels of the conflicting registers are in the same position. The defect of this method is that for the life cycle defined by the PHI instruction, it is assumed that all the channels of the slave registers are alive during this life cycle, and it is impossible to accurately determine the real conflicting slave register channels. Ultimately, the life cycle defined by the PHI instruction will be judged as unable to be merged, resulting in misjudgment of registers when merging. Summary of the invention

[0004] In view of the above problems, the present application provides a register merging method when lifecycle conflicts occur, including the following contents:

[0005] In a first aspect, the present application provides a register merging method when a life cycle conflict occurs, the method comprising:

[0006] For a first register and a second register having a conflict in lifecycle when merged, recalculate the lifecycle of a slave register of the first register and / or the second register; the lifecycle of the slave register includes a lifecycle defined by a PHI instruction and a lifecycle defined by a non-PHI instruction, and the slave register is not necessarily in a survival state within the lifecycle defined by the PHI instruction;

[0007] According to the recalculated life cycle of the slave register, determining whether there is a life cycle conflict in the corresponding slave register when the first register and the second register are merged;

[0008] If not, the merging of the first master register and the second master register is completed based on the slave register.

[0009] Optionally, the recalculating the life cycle of the slave register includes:

[0010] Calculate the survival status of each instruction before and after the slave register including the PHI instruction, and connect all the surviving instructions to form a plurality of continuous program point sets;

[0011] The program point set includes a plurality of continuous program point segments, each of which represents a life cycle of the slave register, and the set of program point segments represents the complete life cycle of the slave register.

[0012] Optionally, the method further includes:

[0013] Based on the complete life cycle of the slave register, it is determined whether the PHI instruction life cycle segment is included in the complete life cycle. If included, it means that the slave register survives in the PHI life cycle. If not, it means that the slave register is not in a survival state in the PHI life cycle.

[0014] Optionally, the calculating the survival status of the slave register before and after each instruction including the PHI instruction includes:

[0015] Define IN Set and Out Set to represent the set of surviving register variables before program point p and the set of surviving register variables after program point p respectively;

[0016] Find all the successor nodes ps of the program point p, and calculate the IN Set (ps) of each successor node. Take the union of all the calculated IN Set (ps) to get the preliminary result of Out Set (p);

[0017] Using the known Out Set (p), remove the register variable v defined by the program point p, and add all the variables introduced by the input expression E of the program point p, so as to obtain IN Set (p), where the program point p is used to define the variable v, and the set E is used to represent the input expression based on which the definition operation is based;

[0018] The survival status of the slave register is determined based on whether the obtained IN Set (p) contains the slave register. If yes, it means the slave register is alive; if no, it means the slave register is not alive.

[0019] Optionally, completing the merging of the first main register and the second main register based on the slave register includes:

[0020] When there is a slave register in the first register, the slave register of the first register and the second register are merged,

[0021] When there is a slave register in the second register, merging the slave registers of the first register and the second register;

[0022] When both the first register and the second register have slave registers, the slave register of the first register and the slave register of the second register are merged.

[0023] In a second aspect, the present application provides a register merging device when a life cycle conflict occurs, the device comprising:

[0024] a calculation unit, configured to recalculate the life cycle of a slave register of a first register and / or a second register having a life cycle conflict when merging; the life cycle of the slave register includes a life cycle defined by a PHI instruction and a life cycle defined by a non-PHI instruction, and the slave register is not necessarily in a survival state within the life cycle defined by the PHI instruction;

[0025] a judging unit, configured to judge, according to the recalculated life cycle of the slave register, whether there is a life cycle conflict in the corresponding slave register when the first register and the second register are merged;

[0026] The merging unit is used to complete the merging of the first main register and the second main register based on the slave register when there is no life cycle conflict between the corresponding slave registers when the first register and the second register are merged.

[0027] Optionally, the calculation unit recalculates the life cycle of the slave register including:

[0028] Calculate a set of surviving register variables from registers before and after each instruction including the PHI instruction, and connect the surviving register variables in the set at all surviving instructions to form a continuous set of program points;

[0029] The program set includes a plurality of continuous program point segments, each of which represents a life cycle of a slave register, and the set of all program point segments represents the complete life cycle of the slave register.

[0030] Optionally, the device further includes a judging subunit, configured to judge, based on the complete life cycle of the slave register, whether the PHI instruction life cycle segment is included in the complete life cycle; if so, it indicates that the slave register survives within the PHI life cycle; if not, it indicates that the slave register is not in a survival state within the PHI life cycle.

[0031] Optionally, the calculating the survival status of the slave register before and after each instruction including the PHI instruction includes:

[0032] Define IN Set and Out Set to represent the set of surviving register variables before program point p and the set of surviving register variables after program point p respectively;

[0033] Find all the successor nodes ps of the program point p, and calculate the IN Set (ps) of each successor node. Take the union of all the calculated IN Set (ps) to get the preliminary result of Out Set (p);

[0034] Using the known Out Set (p), remove the register variable v defined by the program point p, and add all the variables introduced by the input expression E of the program point p, so as to obtain IN Set (p), where the program point p is used to define the variable v, and the set E is used to represent the input expression based on which the definition operation is based;

[0035] The survival status of the slave register is determined based on whether the obtained IN Set (p) contains the slave register. If yes, it means the slave register is alive; if no, it means the slave register is not alive.

[0036] Optionally, the merging unit completing the merging of the first main register and the second main register based on the slave register includes:

[0037] When there is a slave register in the first register, the slave register of the first register and the second register are merged,

[0038] When there is a slave register in the second register, merging the slave registers of the first register and the second register;

[0039] When both the first register and the second register have slave registers, the slave register of the first register and the slave register of the second register are merged.

[0040] In a third aspect, the present application provides a device comprising a memory and a processor, wherein the memory is used to store instructions or codes, and the processor is used to execute the instructions or codes so that the device executes a register merging method when there is a lifecycle conflict introduced in any implementation method of the first aspect.

[0041] In a fourth aspect, the present application provides a computer-readable storage medium storing a code. When the code is executed, a device executing the code implements a register merging method when a lifecycle conflict occurs as described in any implementation of the first aspect.

[0042] The present application provides a register merging method when there is a life cycle conflict. When executing the method, first, for the first register and the second register that have a life cycle conflict when merging, recalculate the life cycle of the slave register of the first register and / or the second register; the life cycle of the slave register includes the life cycle defined by the PHI instruction and the life cycle defined by the non-PHI instruction, and the slave register is not necessarily in a survival state during the life cycle defined by the PHI instruction. According to the recalculated life cycle of the slave register, it is determined whether there is a life cycle conflict in the corresponding slave register when the first register and the second register are merged. If not, the merger of the first master register and the second master register is completed based on the slave register. By recalculating the life cycle of the slave register of the first register and the second register that have a life cycle conflict, and comprehensively considering the life cycle defined by the PHI instruction and the non-PHI instruction, the method can more accurately determine whether the corresponding slave register actually has a life cycle conflict when merging the first master register and the second master register. This method can greatly improve the accuracy of register merging. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] In order to more clearly illustrate the technical solutions in this embodiment or the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0044] Figure 1 A flowchart of a register merging method when a life cycle conflict occurs provided by an embodiment of the present application;

[0045] Figure 2 A schematic diagram of the structure of a register merging device when a life cycle conflict occurs provided in an embodiment of the present application. DETAILED DESCRIPTION

[0046] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0047] Figure 1 A flow chart of a register merging method for life cycle conflicts provided by an embodiment of the present application. Figure 1As shown, the register merging method provided by the embodiment of the present application when the life cycle conflicts may include:

[0048] S101 . For a first register and a second register that have a lifecycle conflict when being merged, recalculate the lifecycle of a slave register of the first register and / or the second register.

[0049] Registers are high-speed storage components inside the central processing unit (CPU) that are used to temporarily store instructions, data, and addresses. In computer architecture, registers usually have limited storage capacity and are accessed very quickly. Register merging is the process of merging the contents of two or more registers into one register, which can be achieved in a variety of ways, such as logical operations, arithmetic operations, or shift operations. In programming and computer architecture, the life cycle of a variable refers to the period from when the variable is created (or memory is allocated) to when it is no longer needed (or memory is released).

[0050] A slave register is a component or partition of a register, used to store data of a specific type or purpose. The life cycle of a slave register includes a life cycle defined by a PHI instruction and a life cycle defined by a non-PHI instruction, and the slave register is not necessarily alive during the life cycle defined by the PHI instruction. The PHI instruction is an instruction used in a compiler, typically in a static single assignment form (SSA) compiler. It is used to implement structures such as conditional branches and loops in a control flow graph, particularly for selecting values ​​returned from different branches.

[0051] Suppose in a compiler, there are two registers R1 and R2, which are used in different branches of a program and need to be merged at a certain point to reduce the number of registers used. However, during the merging process, the compiler finds that there is a life cycle conflict between R1 and R2. The life cycle conflict here means that both R1 and R2 need to store data within a certain period of time, but their life cycles do not completely overlap, resulting in the inability to merge directly. The current judgment method attempts to determine whether it can be merged by analyzing the life cycle of the register. This method usually includes the following steps:

[0052] First, the compiler needs to determine the lifecycles of R1 and R2, including the time points when they start and end. Then, the compiler checks whether there is a conflict in the lifecycles of the two registers. If there is a conflict, that is, they both need to store data for a certain period of time, then the merge will be affected. Finally, the compiler will determine whether the two registers can be merged based on the conflict in the lifecycle.

[0053] However, the above judgment method has defects when processing the life cycle defined by the PHI instruction. Specifically: for the life cycle defined by the PHI instruction (the beginning of its life cycle is at the boundary of a basic block), the compiler may not be able to accurately determine its channel from the register. This is because the PHI instruction is used to select the value returned from different branches in the control flow graph, so the beginning of its life cycle does not correspond to a specific machine instruction. During the life cycle defined by the PHI instruction, since the compiler cannot determine which channel really needs to survive, all channels may be considered alive. This causes the compiler to be unable to accurately determine the real conflicting channels. Due to the above reasons, the compiler may mistakenly believe that R1 and R2 have an unsolvable conflict within the life cycle defined by the PHI instruction, and thus determine that they cannot be merged. This is actually a defect because in some cases, these conflicts may be solvable. That is to say, the current judgment method has defects when processing the life cycle defined by the PHI instruction, and cannot accurately determine the real conflicting channels, resulting in merging failure. In order to solve this problem, the compiler needs to adopt more advanced algorithms and techniques to accurately analyze the life cycle and conflict of registers and determine whether they can be merged. Therefore, in the present application, the life cycle of the slave register of the first register and / or the second register is recalculated to determine whether the first register and the second register can be merged.

[0054] In the embodiment of the present application, recalculating the life cycle of the slave register includes:

[0055] First, calculate the survival status of the slave register before and after each instruction including the PHI instruction. Specifically, the program is divided into a series of program points (or instructions), and each program point p can be expressed as: p:v=E, where v is the defined variable, E is the input expression, and IN Set and Out Set are defined. IN Set(p) represents the set of surviving register variables before entering the program point p, and Out Set(p) represents the set of surviving register variables after exiting the program point p. For each program point p: Out Set(p)=OR(IN Set(ps)), where ps is all the successor nodes of p. This means that the Out Set of point p is the union of all its successor nodes In Set. IN Set(p)=(Out Set(p)–{v})OR vars(E), where v is the variable defined at point p, and E is the input expression used when defining v. vars(E) represents the set of all variables introduced in E.

[0056] Initialize IN Set(p) and Out Set(p) for each program point p in the program, and calculate Out Set: For each program point p, find all its successor nodes ps, and calculate IN Set(ps) for each successor node ps. Take the union of IN Set(ps) of all successor nodes to get the preliminary result of Out Set(p). Calculate IN Set: Using the known Out Set(p), remove the register variable v defined by program point p. Add all variables introduced by the input expression E of program point p to INSet(p). Repeat the above Out Set and IN Set calculation process.

[0057] For each slave register, traverse all program points and check whether the IN Set of each program point contains the slave register. If the IN Set contains the slave register, the slave register is alive before the program point.

[0058] All surviving instructions are connected to form several continuous program point sets, wherein the program point sets include multiple continuous program point fragments, each continuous program point represents a life cycle of the slave register, and the set of program point fragments represents the complete life cycle of the slave register.

[0059] Based on the complete life cycle of the slave register, when recalculating the life cycle segment of the original PHI instruction for the slave register, it is necessary to determine whether the slave register is included in the IN Set (p) at the program point p of the PHI instruction, and at the program point q where the life cycle of the original PHI instruction ends, the slave register is included in its IN Set (p), and the slave register is not included in the Out Set (q), which means that the slave register is alive in the life cycle segment of the original PHI instruction. If not, it means that it is not alive.

[0060] According to this method, the recalculation of the life cycle segment of the original PHI instruction from the register life cycle can be completed.

[0061] S102: According to the recalculated life cycle of the slave register, determine whether there is a life cycle conflict in the corresponding slave register when the first register and the second register are merged.

[0062] It is necessary to obtain the life cycle information of the slave registers corresponding to the first register and the second register, respectively, and at least one of the first register and the second register has a slave register. Then compare the life cycles of the corresponding registers when the first register and the second register are to be merged. For example, when only the first register has a slave register, and the first register and the second register are to be merged, the slave register and the second register of the first register are to be merged. If there is a conflict in the life cycles of the first register and the second register, further determine whether there is a conflict in the life cycles of the slave registers of the first register and the second register. If there is no conflict in their slave register life cycles, the merge may be feasible. Otherwise, the merge may cause incorrect program behavior and should be prohibited.

[0063] For example, for the following instruction %1.dsub_0:qvregs=COPY%2:dvregs, where %1 is the first register and %2 is the second register, to merge %1 and %2, it is necessary to first calculate the lifecycles of %1 and %2. Then, based on the calculation results, it is found that the master registers of %1 and %2 are conflicting, but %1 contains slave registers %1.dsub_0 and %1.dsub_1, so it is necessary to calculate the lifecycles of %1.dsub_0 and %1.dsub_1. At this time, the registers being merged are %1.dsub_0 and %2, so it is necessary to determine whether the lifecycle of %1.dsub_0 conflicts with %2. ​​If not, it means that the source register and destination register of this copy instruction are not conflicting, and the register merge operation can be performed. That is, the merged slave register is not a real conflicting register. On the contrary, if %1.dsub_0 and %2 conflict, the register merge cannot be performed.

[0064] S103: If not, completing the merging of the first master register and the second master register based on the slave register.

[0065] Different merging strategies are adopted according to the existence of slave registers:

[0066] When a slave register exists in the first register but not in the second register: In this case, the slave register of the first register is merged with the second register itself. This usually means integrating the value or function of the second register into the slave register of the first register.

[0067] When the slave register exists in the second register but not in the first register: Similar to the above case, the slave register of the second register is merged with the first register itself.

[0068] When both the first register and the second register have slave registers: In this case, the slave registers of the two registers need to be merged. This may involve more complex operations such as data migration, register renaming or reallocation to ensure that the merged register can correctly store and process the data of the two original registers.

[0069] The above are some specific implementations of a register merging method when a life cycle conflict is provided in an embodiment of the present application. Based on this, the present application also provides a corresponding device. The device provided in the embodiment of the present application will be introduced from the perspective of functional modularization.

[0070] Figure 2 A schematic diagram of a register merging device for life cycle conflicts provided by an embodiment of the present application. Figure 2 As shown, the register merging device 200 for life cycle conflict provided by the embodiment of the present application includes:

[0071] The calculation unit 210 is used to recalculate the life cycle of the slave register of the first register and / or the second register for the first register and / or the second register having a life cycle conflict when merging; the life cycle of the slave register includes a life cycle defined by a PHI instruction and a life cycle defined by a non-PHI instruction, and the slave register is not necessarily in a survival state within the life cycle defined by the PHI instruction;

[0072] A judging unit 220, configured to judge, based on the recalculated life cycle of the slave register, whether there is a life cycle conflict between the corresponding slave registers when the first register and the second register are merged;

[0073] The merging unit 230 is configured to complete the merging of the first master register and the second master register based on the slave register when there is no life cycle conflict between the corresponding slave registers when the first register and the second register are merged.

[0074] In an implementation manner of the embodiment of the present application, the calculation unit recalculates the life cycle of the slave register including:

[0075] Calculate a set of surviving register variables from registers before and after each instruction including the PHI instruction, and connect the surviving register variables in the set at all surviving instructions to form a continuous set of program points;

[0076] The program set includes a plurality of continuous program point segments, each of which represents a life cycle of a slave register, and the set of all program point segments represents the complete life cycle of the slave register.

[0077] In an implementation manner of the embodiment of the present application, the device also includes a judgment subunit, which is used to judge whether the PHI instruction life cycle segment is included in the complete life cycle based on the complete life cycle of the slave register. If it is included, it means that the slave register survives within the PHI life cycle. If not, it means that the slave register is not in a survival state within the PHI life cycle.

[0078] In one implementation of the embodiment of the present application, the calculating of the survival status of the slave register before and after each instruction including the PHI instruction includes:

[0079] Define IN Set and Out Set to represent the set of surviving register variables before program point p and the set of surviving register variables after program point p respectively;

[0080] Find all the successor nodes ps of the program point p, and calculate the IN Set (ps) of each successor node. Take the union of all the calculated IN Set (ps) to get the preliminary result of Out Set (p);

[0081] Using the known Out Set (p), remove the register variable v defined by the program point p, and add all the variables introduced by the input expression E of the program point p, so as to obtain IN Set (p), where the program point p is used to define the variable v, and the set E is used to represent the input expression based on which the definition operation is based;

[0082] The survival status of the slave register is determined based on whether the obtained IN Set (p) contains the slave register. If yes, it means the slave register is alive; if no, it means the slave register is not alive.

[0083] In an implementation of the embodiment of the present application, the merging unit completes the merging of the first main register and the second main register based on the slave register, including:

[0084] When there is a slave register in the first register, the slave register of the first register and the second register are merged,

[0085] When there is a slave register in the second register, merging the slave registers of the first register and the second register;

[0086] When both the first register and the second register have slave registers, the slave register of the first register and the slave register of the second register are merged.

[0087] The embodiments of the present application also provide corresponding devices and computer storage media for implementing the solutions provided by the embodiments of the present application.

[0088] The device includes a memory and a processor, the memory is used to store instructions or codes, and the processor is used to execute the instructions or codes so that the device executes the method described in any embodiment of the present application.

[0089] The computer storage medium stores codes, and when the codes are executed, a device executing the codes implements the method described in any embodiment of the present application.

[0090] Through the description of the above implementation methods, it can be known that those skilled in the art can clearly understand that all or part of the steps in the above-mentioned embodiment method can be implemented by means of software plus a general hardware platform. Based on such an understanding, the technical solution of the present application can be embodied in the form of a software product, which can be stored in a storage medium, such as a read-only memory (ROM) / RAM, a magnetic disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network communication device such as a router) to execute the methods described in each embodiment of the present application or some parts of the embodiments.

[0091] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0092] It should also be noted that the various embodiments in this specification are described in a progressive manner, and the same and similar parts between the various embodiments can refer to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device and apparatus embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can refer to the partial description of the method embodiments. The device and apparatus embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components indicated as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0093] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A register merging method when life cycle conflicts occur, characterized in that: The method comprises: For a first register and a second register having a conflict in lifecycle when merged, recalculate the lifecycle of a slave register of the first register and / or the second register; the lifecycle of the slave register includes a lifecycle defined by a PHI instruction and a lifecycle defined by a non-PHI instruction, and the slave register is not necessarily in a survival state within the lifecycle defined by the PHI instruction; According to the recalculated life cycle of the slave register, determining whether there is a life cycle conflict in the corresponding slave register when the first register and the second register are merged; If not, the merging of the first master register and the second master register is completed based on the slave register.

2. The method according to claim 1, characterized in that The life cycle of recalculating a slave register includes: Calculate the survival status of each instruction before and after the slave register including the PHI instruction, and connect all the surviving instructions to form a plurality of continuous program point sets; The program point set includes a plurality of continuous program point segments, each of which represents a life cycle of the slave register, and the set of program point segments represents the complete life cycle of the slave register.

3. The method according to claim 2, characterized in that The method further comprises: Based on the complete life cycle of the slave register, it is determined whether the PHI instruction life cycle segment is included in the complete life cycle. If included, it means that the slave register survives in the PHI life cycle. If not, it means that the slave register is not in a survival state in the PHI life cycle.

4. The method according to claim 2, characterized in that: The calculating of the survival status of the slave register before and after each instruction including the PHI instruction includes: Define IN Set and Out Set to represent the set of surviving register variables before program point p and the set of surviving register variables after program point p respectively; Find all the successor nodes ps of the program point p, and calculate the IN Set (ps) of each successor node. Take the union of all the calculated IN Set (ps) to get the preliminary result of Out Set (p); Using the known Out Set (p), remove the register variable v defined by the program point p, and add all the variables introduced by the input expression E of the program point p, so as to obtain IN Set (p), where the program point p is used to define the variable v, and the set E is used to represent the input expression based on which the definition operation is based; The survival status of the slave register is determined based on whether the obtained IN Set (p) contains the slave register. If so, it means it is alive; if not, it means it is not alive.

5. The method according to claim 1, characterized in that The merging of the first main register and the second main register based on the slave register comprises: When there is a slave register in the first register, the slave register of the first register and the second register are merged, When there is a slave register in the second register, merging the slave registers of the first register and the second register; When both the first register and the second register have slave registers, the slave register of the first register and the slave register of the second register are merged.

6. A register merging device for life cycle conflicts, characterized in that: The device includes: a calculation unit, configured to recalculate the life cycle of a slave register of a first register and / or a second register having a life cycle conflict when merging; the life cycle of the slave register includes a life cycle defined by a PHI instruction and a life cycle defined by a non-PHI instruction, and the slave register is not necessarily in a survival state within the life cycle defined by the PHI instruction; a judging unit, configured to judge, according to the recalculated life cycle of the slave register, whether there is a life cycle conflict in the corresponding slave register when the first register and the second register are merged; The merging unit is used to complete the merging of the first main register and the second main register based on the slave register when there is no life cycle conflict between the corresponding slave registers when the first register and the second register are merged.

7. The device according to claim 6, characterized in that The life cycle of the calculation unit recalculates the slave registers including: Calculate a set of surviving register variables from registers before and after each instruction including the PHI instruction, and connect the surviving register variables in the set at all surviving instructions to form a continuous set of program points; The program set includes a plurality of continuous program point segments, each of which represents a life cycle of a slave register, and the set of all program point segments represents the complete life cycle of the slave register.

8. The device according to claim 7, characterized in that The device also includes: The judging subunit is used to judge whether the PHI instruction life cycle segment is included in the complete life cycle based on the complete life cycle of the slave register. If included, it means that the slave register survives in the PHI life cycle. If not, it means that the slave register is not in a survival state in the PHI life cycle.

9. A computing device, characterized in that The computing device includes: a memory and a processor; The memory is used to store computer programs; The processor is configured to implement the method according to any one of claims 1 to 5 when executing the computer program.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.

Citation Information

Cited By

  • Register allocation method and device, computer program product and readable storage medium

    CN121658010A