# US 2023/0266950 A1 · Methods and devices for compiler function fusion

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2023/0266950 A1
- Document ID: US20230266950A1
- Status: Published application
- Kind: A1
- Application number: 17/674,903
- Filed: 2022-02-18
- Published: 2023-08-24
- Earliest claimed: 2022-02-18
- Assignees: Huawei Technologies Co., Ltd.
- Applicants: Huawei Technologies Co., Ltd.
- Inventors: Mehrnoosh HEIDARPOUR; Henry KAO; Ehsan AMIRI; Congzhe CAO
- Web page: https://patentgrep.com/patent/US20230266950A1

## CPC

- G06F 8/443: {Optimisation}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A method for fusing functions of a software program is provided. The method includes processing an intermediate representation (IR) of the software program and determining one or more function call candidates capable of fusion based on the processed IR. The method further includes determining similarities between the function call candidates and generating a merged function of the function call candidates based on the determined similarities. The method further includes generating at least one interleaved version of the merged function and determining an optimized function version from among the merged function and the at least one interleaved version. The method further includes generating a fused function based on the determined optimized function version. In addition, a device is provided which includes a processor, and non-transitory computer readable memory having stored thereon machine-readable instructions which when executed by the processor configure the device to execute the methods disclosed herein.

## Claims

### Claim 1

A method, in an electronic device, for fusing functions of a software program, the method comprising:
processing an intermediate representation (IR) of the software program;
determining one or more function call candidates capable of fusion based on the processed IR;
determining similarities between the one or more function call candidates;
generating a merged function of the one or more function call candidates based on the determined similarities;
generating at least one interleaved version of the merged function;
determining an optimized function version from among the merged function and the at least one interleaved version of the merged function; and
generating a fused function based on the determined optimized function version.

### Claim 2 (depends on 1)

The method of claim 1 wherein the one or more function call candidates are consecutive function calls.

### Claim 3 (depends on 1)

The method of claim 1 wherein determining similarities between the one or more function call candidates includes evaluating strongly connected components (SCCs) of each of the one or more function call candidates in relation to SCCs of others of the one or more function call candidates.

### Claim 4 (depends on 3)

The method of claim 3 wherein evaluating SCCs includes at least one of: constructing SCCs;
topologically sorting SCCs; and
comparing SCCs.

### Claim 5 (depends on 1)

The method of claim 1 wherein generating the at least one interleaved version of the merged function includes at least one of:
interleaving software program code;
moving software program code; and
reordering software program code.

### Claim 6 (depends on 1)

The method of claim 1 wherein determining the optimized function version includes determining a benefit estimation of the merged function and the at least one interleaved version of the merged function.

### Claim 7 (depends on 6)

The method of claim 6 wherein determining a benefit estimation includes determining cost models based on predefined heuristics specific to the merged function and the each one of the at least one interleaved version of the merged function.

### Claim 8 (depends on 1)

The method of claim 1 wherein determining the optimized function version includes evaluating the merged function and the at least one interleaved version of the merged function using profile-guided optimization (PGO).

### Claim 9 (depends on 1)

The method of claim 1 wherein the at least one interleaved version includes at least one of:
a loop fusion optimization;
a partial redundancy elimination (PRE) optimization;
a simplification of a control-flow graph (CFG) optimization; and
another type of optimization.

### Claim 10 (depends on 1)

The method of claim 1 wherein generating a merged function includes appending the body of each of the one or more function call candidates to a new skeleton function.

### Claim 11

A device comprising:
a processor; and
non-transitory computer readable memory having stored thereon machine readable instructions which when executed by the processor configure the device to:
process an intermediate representation (IR) of a software program;
determine one or more function call candidates capable of fusion based on the processed IR;
determine similarities between the one or more function call candidates;
generate a merged function of the one or more function call candidates based on the determined similarities;
generate at least one interleaved version of the merged function;
determine an optimized function version from among the merged function and the at least one interleaved version of the merged function; and
generate a fused function based on the determined optimized function version.

### Claim 12 (depends on 11)

The device of claim 11 wherein the one or more function call candidates are consecutive function calls.

### Claim 13 (depends on 11)

The device of claim 11 wherein to determine similarities between the one or more function call candidates includes to evaluate strongly connected components (SCCs) of each of the one or more function call candidates in relation to SCCs of others of the one or more function call candidates.

### Claim 14 (depends on 13)

The device of claim 13 wherein to evaluate SCCs includes at least one of: constructing SCCs;
topologically sorting SCCs; and
comparing SCCs.

### Claim 15 (depends on 11)

The device of claim 11 wherein to generate the at least one interleaved version of the merged function includes at least one of:
to interleave software program code;
to move software program code; and
to reorder software program code.

### Claim 16 (depends on 11)

The device of claim 11 wherein to determine the optimized function version includes to determine a benefit estimation of the merged function and the at least one interleaved version of the merged function.

### Claim 17 (depends on 16)

The device of claim 16 wherein to determine a benefit estimation includes to determine cost models based on predefined heuristics specific to the merged function and the each one of the at least one interleaved version of the merged function.

### Claim 18 (depends on 11)

The device of claim 11 wherein to determine the optimized function version includes to evaluate the merged function and the at least one interleaved version of the merged function using profile-guided optimization (PGO).

### Claim 19 (depends on 11)

The device of claim 11 wherein the at least one interleaved version includes at least one of:
a loop fusion optimization;
a partial redundancy elimination (PRE) optimization;
a simplification of a control-flow graph (CFG) optimization; and
another type of optimization.

### Claim 20 (depends on 11)

The device of claim 11 wherein to generate a merged function includes to append the body of each of the one or more function call candidates to a new skeleton function.
