w9Color

# w9Color - Instruction Scheduling and Optimizations 1...

This preview shows pages 1–9. Sign up to view the full content.

1 Instruction Scheduling and Optimizations

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
2 Programs Optimization and Analysis Note: Code scheduling and register allocation in basic blocks were already two optimization techniques. However, they are important, basic compiler techniques on today’s processors.
3 What is an Optimization? Criterion 1: Code change must be safe An optimizations must not change the answer (the result) of the program. This can be subtle: – Is it safe to do this move? – Code size can be important. Optimizations that increase the code size may be considered unsafe but may also be considered safe. (We will ignore this for now, though) DO i=1,n <loop-invariant expression> ... ENDDO What if the expression is a/n ?

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
4 What is an Optimization? Criterion 2: Code change must be profitable The performance of the transformed program must be better than before. This is sometimes difficult to determine, because: – the compiler does not have sufficient data about machine costs, or the given figures are average costs, or the machine is non-deterministic – the compiler does not have sufficient information about program input data. – the compiler may not have sufficiently powerful analysis techniques. Sometimes profiling is used to alleviate these problems. Profiling works only for some average case! Profiling also has bookkeeping problems. The code size must be smaller (not always important)
5 Interdependence Of Optimizations Usually, optimizations are applied one-by-one. In reality they are interdependent. For example: a = 3 b = 0 IF (b == a-2) a = 5 ENDIF IF (a == 3) print “success” ELSE print “failure” ENDIF Consider applying dead code elimination before constant propagation, dead code elimination after constant propagation constant propagation, dead code elimination, constant propagation, and dead code elimination Unfortunately, compile time is a finite resource …

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
6 Interdependence Of Optimizations Usually, optimizations are applied one-by-one. In reality they are interdependent. For example: a = 3 b = 0 IF (b == a-2) a = 5 ENDIF IF (a == 3) print “success” ELSE print “failure” ENDIF Consider applying dead code elimination before constant propagation, dead code elimination after constant propagation constant propagation, dead code elimination, constant propagation, and dead code elimination Unfortunately, compile time is a finite resource …
7 Interdependence Of Optimizations Usually, optimizations are applied one-by-one. In reality they are interdependent. For example: a = 3 b = 0 IF (0 == 1) a = 5 ENDIF IF (a == 3) print “success” ELSE print “failure” ENDIF Consider applying dead code elimination before constant propagation, dead code elimination after constant propagation constant propagation, dead code elimination, constant propagation, and dead code elimination Unfortunately, compile time is a finite resource …

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
8 Interdependence Of Optimizations Usually, optimizations are applied one-by-one.
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 40

w9Color - Instruction Scheduling and Optimizations 1...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online