Loop inversion ( eng. Loop inversion ) - compiler optimization and loop transformation, during which the While-loop replaced by a branch operator containing the Do-While-cycle . When used properly, this optimization improves performance through pipelining .
C Example
For example, the following code:
int i , a [ 100 ];
i = 0 ;
while ( i < 100 ) {
a [ i ] = 0 ;
i ++ ;
}
as a result of the application of optimization is converted to:
int i , a [ 100 ];
i = 0 ;
if ( i < 100 ) {
do {
a [ i ] = 0 ;
i ++ ;
} while ( i < 100 );
}
Notes
Literature
- Alfred Aho, Monica Lam, Ravi Seti, Jeffrey Ulman. Compilers: principles, technologies and tools = Compilers: Principles, Techniques, and Tools. - 2nd edition. - M .: “Williams”, 2008. - 1184 p. - 1500 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 .