User loginNavigationTake FREE online C/C++ test now!Unix / Linux ProgrammingCode search made simpleYour feedback needed!As a webmaster of this site, I regard you as our most important critic and commentator. We value your opinion and want to know what we are doing right, what we could do better and any other words of wisdom you're willing to pass our way. It would be our greatest motivation which will help us in developing areas you would like to see in this site. We hope you will continue to encourage and support us in our future endeavors.
INDIA |
Compiler Optimization Techniques PART -Icode optimization is a technique in which the code is transformed to improve the performance. Performance here can be execution time, code size or both. Now, let me start away with the common techniques used. Optimization Techniques - 1. Copy Propogation copy propagation is the process of replacing the occurrences of targets of direct assignments with their values ex : x = y; this can be optimized as follows : z = 25 + 3; /* if the value of x is not used elsewhere */ In pipelined process, x = y; 2. Constant Folding Here, the compiler analyzes constant valued expressions and perform calculations at the Ex : j = i + k; This function is modified as follows : j = i + 200; /* Constant Operands are evaluated at compile time */ return j; ii. . . . . return 0; int foo ( void ) . . . . return 0; Care must be taken to ensure that the behaviour of the arithmetic operations on the host architecture 3. Strength Reduction In this method, Expensive operations are replaced with Cheaper ones. ex : y = pow ( x, 2 ); . . . . return 0; int foo ( void ) y = x * x /* the compiler may not do exactly the same */ . . . . return 0; 4. Variable Renaming This is a technique in which variables are renamed. This is mainly helpful in Multiprocessor Ex : res = a + 2; return 0; int foo ( void ) res = a + 2; return 0; Since both those instructions are independant of each other, by renaming the variables, process 5. Common Sub-Expression Elimination The objective here is to eliminate all those expressions that have already been performed. Ex : . . . . return i; We see that 'a + b' is the common Sub-Expression. So by eliminating it, int main ( void ) . . . . return i; contd..
|