1 P3 / 2003
Control-Flow and Low-Level Optimizations
Kostis Sagonas
2 Spring 2003
Outline
- Unreachable-Code Elimination
- Straightening
- If and Loop Simplifications
- Loop Inversion and Unswitching
- Branch Optimizations
- Tail Merging (Cross Jumping)
- Conditional Moves
- Dead-Code Elimination
- Branch Prediction
- Peephole Optimization
- Machine Idioms & Instruction Combining
Kostis Sagonas
3 Spring 2003
Unreachable-Code Elimination
Unreachable code is code that cannot be executed, regardless of the input data
– code that is never executable for any input data – code that has become unreachable due to a previous compiler transformation.
Unreachable code elimination removes this code.
– Doing so, reduces the code space; – improves instruction-cache utilization; – enables other control-flow transformations.
Kostis Sagonas
4 Spring 2003
Unreachable-Code Elimination
f = a + c g = e a = e +c c = a + b d = c e > c f = c – g b = c + 1 d = 4 * a e = d – 7 f = e + 2 entry exit h = e + 1 e < a c = a + b d = c e > c f = c – g b = c + 1 d = 4 * a e = d – 7 f = e + 2 entry exit
Kostis Sagonas
5 Spring 2003
Outline
- Unreachable-Code Elimination
- Straightening
- If and Loop Simplifications
- Loop Inversion and Unswitching
- Branch and Useless Control-Flow Optimizations
- Tail Merging (Cross Jumping)
- Conditional Moves
- Dead-Code Elimination
- Branch Prediction
- Peephole Optimization
- Machine Idioms & Instruction Combining
Kostis Sagonas
6 Spring 2003