Algebraic Simplification and Reduction in Strength Algebraic identities can be used to eliminate three-address statements -X=X+0;X=x*1 Reduction-in-strength transformations can be applied to replace expensive operations -x2 power(x,2);x*x Fixed-point multiplication or division;shift Floating-point division by a constant can be approximated as multiplication by a constant CS308 Compiler Theory 6
Algebraic Simplification and Reduction in Strength • Algebraic identities can be used to eliminate three-address statements – x = x+0; x=x*1 • Reduction -in -strength transformations can be applied to replace strength transformations can be applied to replace expensive operations – x2 ; power(x, 2); x*x – Fixed-point multiplication or division; shift – Floating-point division by a constant can be approximated as multiplication by a constant CS308 Compiler Theory 16
Use of Machine Idioms The target machine may have hardware instructions to implement certain specific operations efficiently. Using these instructions can reduce execution time significantly. ·Example: some machines have auto-increment and auto-decrement addressing modes. The use of the modes greatly improves the quality of code when pushing or popping a stack as in parameter passing. These modes can also be used in code for statements like x=x+1. CS308 Compiler Theory 17
Use of Machine Idioms • The target machine may have hardware instructions to implement certai ifi i ffi i l in specific operat ions effi c ient ly. • Using these instructions can reduce execution time significantly. • Example: – some machines have auto-increment and auto-decrement addressing modes. – The use of the modes greatly improves the quality of code when pushing or popping a stack The use of the modes greatly improves the quality of code when pushing or popping a stack as in parameter passing. – These modes can also be used in code for statements like x = x + 1 . CS308 Compiler Theory 17