Structural Optimization Flashcards
(10 cards)
What is the first optimization?
Strength Reduction
What is the second optimization?
Loop Unwinding
What is the third optimization?
Loop-Invariant Code Motion
What is the fourth optimization?
Copy Propagation
What is the fifth optimization?
Tail-Recursion Removal
What is an example of strength reduction?
Simplifying mathematical operations, such as:
- changing multiplication by powers of 2 to bit shift
- changing small multiplication values to several addition functions
What is an example of loop unwinding?
Reducing the number of iterations a loop needs to complete, such as:
- if a loop executes twice, remove the loop and add the body twice
- if a loop has only a method calling using the declared variable, and has a significant number of iterations to complete, reduce the number of iterations by calling the method several times with the updated value as needed
What is an example of loop-invariant code motion?
Moving constant operations that never change outside of the loop, so that they are only calculated once
What is an example of copy propagation?
When a variable is assigned a value, but the variable is never used, ignore the variable and in its place you the assigned value
What is an example of tail-recursion removal?
Converting the function using tail-recursion to a loop, where the needed variables are declared outside the loop