Compiler Function Fusion via Intermediate Representation Analysis
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing automatic optimization tools for computer code are limited in their ability to optimize code efficiently, often resulting in high code size overhead and increased compilation time, and fail to detect optimization opportunities due to code being separated into different functions.
Innovation Solution
The method involves processing an intermediate representation of a software program to identify function call candidates, determining similarities between them, generating a merged function, and creating optimized interleaved versions, which reduces code size and compilation time by fusing functions and applying optimizations like loop fusion and control-flow graph simplification.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Productivity
If automatic optimization tools are used to optimize code, then code optimization is achieved, but code size overhead increases and compilation time increases
Solution Approach 1:
The patent merges multiple consecutive function calls into a single fused function by analyzing their intermediate representations and identifying fusion opportunities. This combining approach reduces the number of separate function calls and their associated overhead, achieving code optimization without proportionally increasing compilation time or code size
Solution Approach 2:
The patent performs preliminary analysis of function call sequences during compilation to identify candidates for fusion before generating optimized code. By detecting fusion opportunities in advance through intermediate representation analysis and similarity evaluation, the compiler can optimize code structure proactively, reducing both code size and compilation time overhead
2Ease of manufacture
If functions are separated into different functions, then code modularity is maintained, but optimization opportunities are lost
Solution Approach 1:
The patent combines multiple separated function calls into a fused function while preserving the modular structure of the original code. By working with intermediate representations and analyzing function similarities, the system identifies when separated functions can be merged for optimization without compromising overall code modularity
Solution Approach 2:
The patent uses intermediate representation as an intermediary layer between the original source code and the optimized output. This intermediary allows the compiler to analyze and fuse functions at a representation level without directly modifying the modular structure of the source code, thereby maintaining modularity while enabling optimization opportunities
3Productivity
If inlining techniques are used to optimize code, then function call overhead is reduced, but code size increases significantly
Solution Approach 1:
Instead of inlining each function call separately (which duplicates code), the patent merges multiple consecutive function calls into a single fused function. This approach reduces function call overhead while avoiding the code size explosion that would result from multiple inlines, as the fused function is generated once and called once
Data Source
AI summary
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.


