Download presentation
Presentation is loading. Please wait.
Published byΚρίος Δαγκλής Modified over 6 years ago
7
For Example: User level quicksort program Three address code
8
Flow graph
11
For Block B5
12
For Block B5
17
MOV a, R0 ADD b, R0 MOV c, R1 SUB d, R1 MOV R0, t1 MOV e, R0
For Example: (a+b)+(e+(c-d)) t1: = a+b t2:= c-d t3:=e+t2 t4=t1+t3 Instruction order as: MOV a, R0 ADD b, R0 MOV c, R1 SUB d, R1 MOV R0, t1 MOV e, R0 ADD R0, R1 MOV t1, R0 ADD R1, R0 MOV R0,t4
18
If, we change the above instructions order as:
t2:= c-d t3:=e+t2 t1: = a+b t4=t1+t3 Now we get the improved cost as MOV c, R0 SUB d, R0 MOV e, R1 ADD R0, R1 MOV a, R0 ADD b, R0 ADD R1, R0 MOV R0,t4
19
Inter-Procedural Optimization
In this technique, we are used all kinds of optimization techniques to improve the performance of the program. a) Tail call & tail recursion elimination Transformation that applies to calls Reduce procedure-call overhead and enable additional optimizations A call from procedure f() to procedure g() is a tail call if the only thing f() does, after g() returns to it, is itself return The call is tail recursive if f() and g() are the same b) In-lining Replaces calls to procedures with copies of their bodies Converts calls from opaque (not transparent) objects to local code Exposes the “effects” of the called procedure Extends the compilation region Language support: the inline attribute But the compiler can decide per call-site, rather than per -procedure
20
d) Link Time or Compile Time
c) Leaf routine optimization A procedure that is a leaf in the call graph. It calls no other procedures. Simplifies the way parameters are passed to a leaf routine. Removes much of the procedure calling and return. Depends on the calling convention and temporary storage requirements. d) Link Time or Compile Time Mainly extensions to graph coloring. Involves interprocedural live variable analysis. Tries to minimize save/restore overheads. Procedures in different sub-trees of the call graph can share registers.
21
e) Aggregation of global references
Link-time optimization. Collect global data into an area that can be referenced by short offsets. Avoids need to calculate “high order” bits. Reserve global pointer (gp) register during compilation. Extension: Sort the global objects smallest to largest to maximize the number of objects accessible by the global pointer.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.