Scalar Code Reduction via Shortest Path Routing in Loops
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Vectorizing compilers face difficulties in reducing the number of scalar instructions required in loops, particularly due to the computational complexity of identifying common subexpressions, which is not well addressed by typical compilers.
Innovation Solution
A compiler system that uses strength reduction and invariant hoisting, combined with a mechanism for finding shortest path routes through expressions with common relationships, and pruning routines to reduce the number of expressions, enabling efficient reduction of scalar operations by computing cost matrices and replacing expressions with less computationally expensive chains.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Productivity
If traditional compiler methods (hoisting invariants and identifying common subexpressions) are used to reduce scalar instructions, then the number of scalar computations is reduced, but the computational complexity and processing time increase significantly
Solution Approach 1:
The patent segments the problem of identifying common subexpressions by focusing only on expressions containing loop induction variables. This segmentation reduces the search space from all possible expressions to a specific subset, making the analysis computationally tractable while still achieving significant scalar instruction reduction through shortest path routing among the segmented expressions.
Solution Approach 2:
The patent performs preliminary classification of expressions to identify those containing loop induction variables before applying the expensive shortest path analysis. This preliminary action filters out irrelevant expressions in advance, reducing the computational burden of the subsequent optimization phase and overall compiler processing time.
2Productivity
If comprehensive common subexpression identification is performed, then more redundant calculations are eliminated, but the algorithm becomes computationally intractable
Solution Approach 1:
The patent applies local quality by treating expressions containing loop induction variables differently from other expressions. Instead of applying uniform complex analysis to all expressions, the patent focuses computational resources only on the local subset of expressions that contain loop induction variables, where the potential for common subexpressions is highest and most beneficial.
Solution Approach 2:
The patent performs partial action by identifying common subexpressions only within the subset of expressions containing loop induction variables, rather than performing exhaustive analysis on all expressions. This partial approach achieves sufficient redundancy elimination for significant performance improvement while keeping the algorithm tractable.
Data Source
AI summary
This document discusses, among other things, a system and method computing the shortest path expression in a loop having a plurality of expressions. Candidate expressions in the loop are identified and partitioned into sets. A cost matrix is computed as a function of the sets. Paths are found through the cost matrix and, if there are cycles in the paths, the cycles are broken. One or more shortest path expressions are generated as a function of the paths and one or more of the expressions in the loop are replaced with the shortest path expressions.


