Splitting the body of a cycle ( English loop fission ) is a compiler optimization that splits a cycle in a program into several cycles, each of which has the same index boundaries, but contains only part of the body of the original cycle.
For example, the following code:
int i , a [ 100 ], b [ 100 ];
for ( i = 0 ; i < 100 ; i ++ ) {
a [ i ] = 1 ;
b [ i ] = 2 ;
}
as a result of applying optimization, it is converted to:
int i , a [ 100 ], b [ 100 ];
for ( i = 0 ; i < 100 ; i ++ ) {
a [ i ] = 1 ;
}
for ( i = 0 ; i < 100 ; i ++ ) {
b [ i ] = 2 ;
}
The key objective of such optimizations is to reduce the number of loop operations. Here, the main optimization method is splitting the cycle into several cycles, for each of which the number of instructions needed to pack the body of the cycle is strictly less than the number of instructions for the original cycle.
Distribution is useful for isolating cyclic dependencies by data in preparation for loop vectorization, for permuting loops or increasing locality by reducing the total amount of data referenced during the complete execution of each cycle.
Notes
See also
- Merge cycles
Literature
- Alfred Aho, Monica Lam, Ravi Seti, Jeffrey Ullman. Compilers: principles, technologies and tools = Compilers: Principles, Techniques, and Tools. - 2nd edition. - M .: "Williams", 2008. - 1184 p. - 1,500 copies - ISBN 978-5-8459-1349-4 .
- Steven S. Muchnick. Advanced Compiler Design and Implementation. - 5th edition. - San Francisco: Morgan Kaufmann Publishers , 1997 .-- 856 p. - ISBN 1-55860-320-4 .
- Kennedy, Ken; & Allen, Randy. Optimizing Compilers for Modern Architectures: A Dependence-based Approach. - Morgan Kaufmann, 2001. - ISBN 1-55860-286-0 .