w9Color - Instruction Scheduling and Optimizations 1...

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

View Full Document Right Arrow Icon
1 Instruction Scheduling and Optimizations
Background image of page 1

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

View Full DocumentRight Arrow Icon
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.
Background image of page 2
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 ?
Background image of page 3

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

View Full DocumentRight Arrow Icon
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)
Background image of page 4
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 …
Background image of page 5

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

View Full DocumentRight Arrow Icon
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 …
Background image of page 6
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 …
Background image of page 7

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

View Full DocumentRight Arrow Icon
8 Interdependence Of Optimizations Usually, optimizations are applied one-by-one.
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

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 Right Arrow Icon
Ask a homework question - tutors are online