SlideShare a Scribd company logo
1 of 46
CODE OPTIMIZATION
PRSENTED BY:
SANJEEV KUMAR……
DEPT:-IT.
ASSAM UNIVERSITY ,SILCHAR
Design Of a Compiler
Lexical Analysis
Syntax Analysis
Intermediate Code Generation
Code Generation
Code Optimization
Table
Mgmt
Routine
Error
Handling
Routine
Source code
Object code
What is optimization?
 In computing, optimization is the process of modifying a system to
make some aspect of it work more efficiently or use fewer resources.
For instance, a computer program may be optimized so that it
executes more rapidly, or is capable of operating with less memory
storage or other resources, or draw less power. The system may be a
single computer program, a collection of computers or even an entire
network such as the internet.
Levels' of optimization
Optimization can occur at a number of 'levels':
 Design level
At the highest level, the design may be optimized to make best
use of the available resources. The implementation of this
design will benefit from the use of suitable efficient algorithms
and the implementation of these algorithms will benefit from
writing good quality code. The architectural design of a system
overwhelmingly affects its performance. The choice of
algorithm affects efficiency more than any other item of the
design.
 Compile level
Use of an optimizing compiler tends to ensure that the
executable program is optimized at least as much as the
compiler can predict.
 Assembly level
At the lowest level, writing code using an Assembly language
designed for a particular hardware platform will normally produce
the most efficient code since the programmer can take advantage of
the full repertoire of machine instructions. The operating systems of
most machines has been traditionally written in Assembler code for
this reason.
 Runtime
Just In Time Compiler and assembler programmers are able to
perform runtime optimization.
When to optimize ?
Optimization is often performed at the end of the
development stage since it
• reduces readability
• adds code that is used to improve the performance.
Criteria For optimization
An optimization must preserve the meaning of a
program :
-Cannot change the output produced for any input
-Can not introduce an error
optimization should, on average, speed up
programs
Transformation should be worth the effort
Improvements can be made at various phases:
Source Code:
-Algorithms transformations can produce spectacular improvements
-Profiling can be helpful to focus a programmer’s attention on important
code.
Intermediate Code:
-Compiler can improve loops, procedure calls and address calculations
-Typically only optimizing compilers include this phase
Target Code:
-Compilers can use registers efficiently
-Peephole transformation can be applied
Types of Code optimization
 Common Sub-expression Removal
 Dead Code Optimization
 Loop Optimization
Common Sub expression elimination
Common Sub expression elimination is a optimization that
searches for instances of identical expressions (i.e they all
evaluate the same value), and analyses whether it is
worthwhile replacing with a single variable holding the
computed value.
a=b * c + g
d=b * c * d
temp=b * c
a=temp + g
d=temp * d
Dead Code elimination is a compiler optimization that removes code that
does not affect a program. Removing such code has two benefits It shrinks
program size, an important consideration in some contexts. It lets the running
program avoid executing irrelevant operations, which reduces its running
time.
Dead Code elimination is of two types
Unreachable Code
Redundant statement
Dead code Optimization:
Unreachable Code
In Computer Programming, Unreachable Code or dead code is code that
exists in the source code of a program but can never be executed.
Program Code
If (a>b)
m=a
elseif (a<b)
m=b
elseif (a==b)
m=0
else
m=-1
Optimized Code
If (a>b)
m=a
elseif (a<b)
m=b
else
m=0
Redundant Code
Redundant Code is code that is executed but has
no effect on the output from a program
main(){
int a,b,c,r;
a=5;
b=6;
c=a + b;
r=2;
r++;
printf(“%d”,c);
}
Adding time & space complexity
Loop optimization
Loop optimization plays an important role in improving
the performance of the source code by reducing overheads
associated with executing loops.
Loop Optimization can be done by removing:
• Loop invariant
• Induction variables
Loop Invariant
i = 1
s= 0
do{
s= s + i
a =5
i = i + 1
{
while (i < =n)
i = 1
s= 0
a =5
do{
s= s + i
i = i + 1
{
while (i < =n)
Bringing a=5 outside the do while loop, is called code
motion.
Induction variables
i = 1
s= 0
S1=0
S2=0
while (i < =n)
{
s= s + a[ i ]
t1 = i * 4
s= s + b[ t1 ]
t2 = t1 +2
s2= s2 + c[ t2 ]
i = i + 1
}
i = 1
s= 0
S1=0
S2=0
t2=0
while (i < =n)
{
s= s + a[ i ]
t1 = t1+ 4
s= s + b[ t1 ]
s2= s2 + c[t1 +2 ]
i = i + 1
}
t1,t2 are induction variables. i is inducing t1 and t1 is inducing t2
“+” replaced “ * ”,
t1 was made
independent of i
Common Sub-expression Removal
 It is used to remove redundant computations which usually
improves the execution time of a program.
Three Address Code of Quick Sort
i = m - 1i = m - 1
j = nj = n
tt11 =4 * n=4 * n
v = a[tv = a[t11]]
i = i + 1i = i + 1
tt22 = 4 * i= 4 * i
tt33 = a[t= a[t22]]
if tif t33 < v goto (5)< v goto (5)
j = j – 1j = j – 1
tt44 = 4 * j= 4 * j
tt55 = a[t= a[t44]]
if tif t55 > v goto (9)> v goto (9)
if i >= j goto (23)if i >= j goto (23)
tt66 = 4 * i= 4 * i
x = a[tx = a[t66]]
11
22
33
44
55
66
77
88
99
1010
1111
1212
1313
1414
1515
tt77 = 4 * I= 4 * I
tt88 = 4 * j= 4 * j
tt99 = a[t= a[t88]]
a[ta[t77] = t] = t99
tt1010 = 4 * j= 4 * j
a[ta[t1010] = x] = x
goto (5)goto (5)
tt1111 = 4 * I= 4 * I
x = a[tx = a[t1111]]
tt1212 = 4 * i= 4 * i
tt1313 = 4 * n= 4 * n
tt1414 = a[t= a[t1313]]
a[ta[t1212] = t] = t1414
tt1515 = 4 * n= 4 * n
a[ta[t ] = x] = x
1616
1717
1818
1919
2020
2121
2222
2323
2424
2525
2626
2727
2828
2929
3030
Find The Basic Block
i = m - 1i = m - 1
j = nj = n
tt11 =4 * n=4 * n
v = a[tv = a[t11]]
i = i + 1i = i + 1
tt22 = 4 * i= 4 * i
tt33 = a[t= a[t22]]
if tif t33 < v goto (5)< v goto (5)
j = j – 1j = j – 1
tt44 = 4 * j= 4 * j
tt55 = a[t= a[t44]]
if tif t55 > v goto (9)> v goto (9)
if i >= j goto (23)if i >= j goto (23)
tt66 = 4 * i= 4 * i
x = a[tx = a[t66]]
11
22
33
44
55
66
77
88
99
1010
1111
1212
1313
1414
1515
tt77 = 4 * I= 4 * I
tt88 = 4 * j= 4 * j
tt99 = a[t= a[t88]]
a[ta[t77] = t] = t99
tt1010 = 4 * j= 4 * j
a[ta[t1010] = x] = x
goto (5)goto (5)
tt1111 = 4 * i= 4 * i
x = a[tx = a[t1111]]
tt1212 = 4 * i= 4 * i
tt1313 = 4 * n= 4 * n
tt1414 = a[t= a[t1313]]
a[ta[t1212] = t] = t1414
tt1515 = 4 * n= 4 * n
a[ta[t ] = x] = x
1616
1717
1818
1919
2020
2121
2222
2323
2424
2525
2626
2727
2828
2929
3030
Flow Graph
i = m - 1i = m - 1
j = nj = n
tt11 =4 * n=4 * n
v = a[tv = a[t11]]
i = i + 1i = i + 1
tt22 = 4 * i= 4 * i
tt33 = a[t= a[t22]]
if tif t33 < v goto B< v goto B22
j = j – 1j = j – 1
tt44 = 4 * j= 4 * j
tt55 = a[t= a[t44]]
if tif t55 > v goto B> v goto B33
if i >= j goto B6
tt66 = 4 * i= 4 * i
x = a[tx = a[t66]]
tt77 = 4 * i= 4 * i
tt88 = 4 * j= 4 * j
tt99 = a[t= a[t88]]
a[ta[t77] = t] = t99
tt1010 = 4 * j= 4 * j
a[ta[t1010] = x] = x
goto Bgoto B22
tt1111 = 4 * i= 4 * i
x = a[tx = a[t1111]]
tt1212 = 4 * i= 4 * i
tt1313 = 4 * n= 4 * n
tt1414 = a[t= a[t1313]]
a[ta[t1212] = t] = t1414
tt1515 = 4 * n= 4 * n
a[ta[t1515] = x] = x
B1
B2
B3
B4
B5 B6
Common Subexpression Elimination
i = m - 1i = m - 1
j = nj = n
tt11 =4 * n=4 * n
v = a[tv = a[t11]]
i = i + 1i = i + 1
tt22 = 4 * i= 4 * i
tt33 = a[t= a[t22]]
if tif t33 < v goto B< v goto B22
j = j – 1j = j – 1
tt44 = 4 * j= 4 * j
tt55 = a[t= a[t44]]
if tif t55 > v goto B> v goto B33
if i >= j goto B6
tt66 = 4 * i= 4 * i
x = a[tx = a[t66]]
tt77 = 4 * i= 4 * i
tt88 = 4 * j= 4 * j
tt99 = a[t= a[t88]]
a[ta[t77] = t] = t99
tt1010 = 4 * j= 4 * j
a[ta[t1010] = x] = x
goto Bgoto B22
tt1111 = 4 * i= 4 * i
x = a[tx = a[t1111]]
tt1212 = 4 * i= 4 * i
tt1313 = 4 * n= 4 * n
tt1414 = a[t= a[t1313]]
a[ta[t1212] = t] = t1414
tt1515 = 4 * n= 4 * n
a[ta[t1515] = x] = x
B1
B2
B3
B4
B5 B6
Common Subexpression Elimination
i = m - 1i = m - 1
j = nj = n
tt11 =4 * n=4 * n
v = a[tv = a[t11]]
i = i + 1i = i + 1
tt22 = 4 * i= 4 * i
tt33 = a[t= a[t22]]
if tif t33 < v goto B< v goto B22
j = j – 1j = j – 1
tt44 = 4 * j= 4 * j
tt55 = a[t= a[t44]]
if tif t55 > v goto B> v goto B33
if i >= j goto B6
tt66 = 4 * i= 4 * i
x = a[tx = a[t66]]
tt88 = 4 * j= 4 * j
tt99 = a[t= a[t88]]
a[a[tt66] = t] = t99
tt1010 = 4 *= 4 *
jj
a[ta[t1010] = x] = x
goto Bgoto B22
tt1111 = 4 * i= 4 * i
x = a[tx = a[t1111]]
tt1212 = 4 * i= 4 * i
tt1313 = 4 * n= 4 * n
tt1414 = a[t= a[t1313]]
a[ta[t1212] = t] = t1414
tt1515 = 4 * n= 4 * n
a[ta[t1515] = x] = x
B1
B2
B3
B4
B5 B6
Common Subexpression Elimination
i = m - 1i = m - 1
j = nj = n
tt11 =4 * n=4 * n
v = a[tv = a[t11]]
i = i + 1i = i + 1
tt22 = 4 * i= 4 * i
tt33 = a[t= a[t22]]
if tif t33 < v goto B< v goto B22
j = j – 1j = j – 1
tt44 = 4 * j= 4 * j
tt55 = a[t= a[t44]]
if tif t55 > v goto B> v goto B33
if i >= j goto B6
tt66 = 4 * i= 4 * i
x = a[tx = a[t66]]
tt88 = 4 * j= 4 * j
tt99 = a[t= a[t88]]
a[a[tt66] = t] = t99
a[a[tt88] = x] = x
goto Bgoto B22
tt1111 = 4 *i= 4 *i
x = a[tx = a[t1111]]
tt1212 = 4 * i= 4 * i
tt1313 = 4 * n= 4 * n
tt1414 = a[t= a[t1313]]
a[ta[t1212] = t] = t1414
tt1515 = 4 * n= 4 * n
a[ta[t1515] = x] = x
B1
B2
B3
B4
B5 B6
Common Subexpression Elimination
i = m - 1i = m - 1
j = nj = n
tt11 =4 * n=4 * n
v = a[tv = a[t11]]
i = i + 1i = i + 1
tt22 = 4 * i= 4 * i
tt33 = a[t= a[t22]]
if tif t33 < v goto B< v goto B22
j = j – 1j = j – 1
tt44 = 4 * j= 4 * j
tt55 = a[t= a[t44]]
if tif t55 > v goto B> v goto B33
if i >= j goto B6
tt66 = 4 * i= 4 * i
x = a[tx = a[t66]]
tt88 = 4 * j= 4 * j
tt99 = a[t= a[t88]]
a[a[tt66] = t] = t99
a[a[tt88] = x] = x
goto Bgoto B22
tt1111 = 4 * i= 4 * i
x = a[tx = a[t1111]]
tt1212 = 4 * i= 4 * i
tt1313 = 4 * n= 4 * n
tt1414 = a[t= a[t1313]]
a[ta[t1212] = t] = t1414
tt1515 = 4 * n= 4 * n
a[ta[t1515] = x] = x
B1
B2
B3
B4
B5 B6
Common Subexpression Elimination
i = m - 1i = m - 1
j = nj = n
tt11 =4 * n=4 * n
v = a[tv = a[t11]]
i = i + 1i = i + 1
tt22 = 4 * i= 4 * i
tt33 = a[t= a[t22]]
if tif t33 < v goto B< v goto B22
j = j – 1j = j – 1
tt44 = 4 * j= 4 * j
tt55 = a[t= a[t44]]
if tif t55 > v goto B> v goto B33
if i >= j goto B6
tt66 = 4 * i= 4 * i
x = a[tx = a[t66]]
tt88 = 4 * j= 4 * j
tt99 = a[t= a[t88]]
a[a[tt66] = t] = t99
a[a[tt88] = x] = x
goto Bgoto B22
tt1111 = 4 * i= 4 * i
x = a[tx = a[t1111]]
tt1313 = 4 * n= 4 * n
tt1414 = a[t= a[t1313]]
a[a[tt1111] = t] = t1414
tt1515 = 4 * n= 4 * n
a[ta[t1515] = x] = x
B1
B2
B3
B4
B5 B6
Common Subexpression Elimination
i = m - 1i = m - 1
j = nj = n
tt11 =4 * n=4 * n
v = a[tv = a[t11]]
i = i + 1i = i + 1
tt22 = 4 * i= 4 * i
tt33 = a[t= a[t22]]
if tif t33 < v goto B< v goto B22
j = j – 1j = j – 1
tt44 = 4 * j= 4 * j
tt55 = a[t= a[t44]]
if tif t55 > v goto B> v goto B33
if i >= j goto B6
tt66 = 4 * i= 4 * i
x = a[tx = a[t66]]
tt88 = 4 * j= 4 * j
tt99 = a[t= a[t88]]
a[a[tt66] = t] = t99
a[a[tt88] = x] = x
goto Bgoto B22
tt1111 = 4 * i= 4 * i
x = a[tx = a[t1111]]
tt1313 = 4 * n= 4 * n
tt1414 = a[t= a[t1313]]
a[a[tt1111] = t] = t1414
a[a[tt1313] = x] = x
B1
B2
B3
B4
B5 B6
Common Subexpression Elimination
i = m - 1i = m - 1
j = nj = n
tt11 =4 * n=4 * n
v = a[tv = a[t11]]
i = i + 1i = i + 1
tt22 = 4 * i= 4 * i
tt33 = a[t= a[t22]]
if tif t33 < v goto B< v goto B22
j = j – 1j = j – 1
tt44 = 4 * j= 4 * j
tt55 = a[t= a[t44]]
if tif t55 > v goto B> v goto B33
if i >= j goto B6
tt66 = 4 * i= 4 * i
x = a[tx = a[t66]]
tt88 = 4 * j= 4 * j
tt99 = a[t= a[t88]]
a[a[tt66] = t] = t99
a[a[tt88] = x] = x
goto Bgoto B22
tt1111 = 4 * i= 4 * i
x = a[tx = a[t1111]]
tt1313 = 4 * n= 4 * n
tt1414 = a[t= a[t1313]]
a[a[tt1111] = t] = t1414
a[a[tt1313] = x] = x
B1
B2
B3
B4
B5 B6
Common Subexpression Elimination
i = m - 1i = m - 1
j = nj = n
tt11 =4 * n=4 * n
v = a[tv = a[t11]]
i = i + 1i = i + 1
tt22 = 4 * i= 4 * i
tt33 = a[t= a[t22]]
if tif t33 < v goto B< v goto B22
j = j – 1j = j – 1
tt44 = 4 * j= 4 * j
tt55 = a[t= a[t44]]
if tif t55 > v goto B> v goto B33
if i >= j goto B6
x = a[x = a[tt22]]
tt88 = 4 * j= 4 * j
tt99 = a[t= a[t88]]
a[a[tt22] = t] = t99
a[a[tt88] = x] = x
goto Bgoto B22
tt1111 = 4 * i= 4 * i
x = a[tx = a[t1111]]
tt1313 = 4 * n= 4 * n
tt1414 = a[t= a[t1313]]
a[a[tt1111] = t] = t1414
a[a[tt1313] = x] = x
B1
B2
B3
B4
B5 B6
Common Subexpression Elimination
i = m - 1i = m - 1
j = nj = n
tt11 =4 * n=4 * n
v = a[tv = a[t11]]
i = i + 1i = i + 1
tt22 = 4 * i= 4 * i
tt33 = a[t= a[t22]]
if tif t33 < v goto B< v goto B22
j = j – 1j = j – 1
tt44 = 4 * j= 4 * j
tt55 = a[t= a[t44]]
if tif t55 > v goto B> v goto B33
if i >= j goto B6
x = tx = t33
tt88 = 4 * j= 4 * j
tt99 = a[t= a[t88]]
a[a[tt22] = t] = t99
a[a[tt88] = x] = x
goto Bgoto B22
tt1111 = 4 * i= 4 * i
x = a[tx = a[t1111]]
tt1313 = 4 * n= 4 * n
tt1414 = a[t= a[t1313]]
a[a[tt1111] = t] = t1414
a[a[tt1313] = x] = x
B1
B2
B3
B4
B5 B6
Common Subexpression Elimination
i = m - 1i = m - 1
j = nj = n
tt11 =4 * n=4 * n
v = a[tv = a[t11]]
i = i + 1i = i + 1
tt22 = 4 * i= 4 * i
tt33 = a[t= a[t22]]
if tif t33 < v goto B< v goto B22
j = j – 1j = j – 1
tt44 = 4 * j= 4 * j
tt55 = a[t= a[t44]]
if tif t55 > v goto B> v goto B33
if i >= j goto B6
x = tx = t33
a[a[tt22] = t] = t55
a[a[tt44] = x] = x
goto Bgoto B22
tt1111 = 4 * i= 4 * i
x = a[tx = a[t1111]]
tt1313 = 4 * n= 4 * n
tt1414 = a[t= a[t1313]]
a[a[tt1111] = t] = t1414
a[a[tt1313] = x] = x
B1
B2
B3
B4
B5 B6
Common Subexpression Elimination
i = m - 1i = m - 1
j = nj = n
tt11 =4 * n=4 * n
v = a[tv = a[t11]]
i = i + 1i = i + 1
tt22 = 4 * i= 4 * i
tt33 = a[t= a[t22]]
if tif t33 < v goto B< v goto B22
j = j – 1j = j – 1
tt44 = 4 * j= 4 * j
tt55 = a[t= a[t44]]
if tif t55 > v goto B> v goto B33
if i >= j goto B6
x = tx = t33
a[a[tt22] = t] = t55
a[a[tt44] = x] = x
goto Bgoto B22
x = tx = t33
tt1414 = a[t= a[t11]]
a[a[tt22] = t] = t1414
a[a[tt11] = x] = x
B1
B2
B3
B4
B5 B6
Similarly for B6
Dead Code Elimination
i = m - 1i = m - 1
j = nj = n
tt11 =4 * n=4 * n
v = a[tv = a[t11]]
i = i + 1i = i + 1
tt22 = 4 * i= 4 * i
tt33 = a[t= a[t22]]
if tif t33 < v goto B< v goto B22
j = j – 1j = j – 1
tt44 = 4 * j= 4 * j
tt55 = a[t= a[t44]]
if tif t55 > v goto B> v goto B33
if i >= j goto B6
x = tx = t33
a[a[tt22] = t] = t55
a[a[tt44] = x] = x
goto Bgoto B22
x = tx = t33
tt1414 = a[t= a[t11]]
a[a[tt22] = t] = t1414
a[a[tt11] = x] = x
B1
B2
B3
B4
B5 B6
Dead Code Elimination
i = m - 1i = m - 1
j = nj = n
tt11 =4 * n=4 * n
v = a[tv = a[t11]]
i = i + 1i = i + 1
tt22 = 4 * i= 4 * i
tt33 = a[t= a[t22]]
if tif t33 < v goto B< v goto B22
j = j – 1j = j – 1
tt44 = 4 * j= 4 * j
tt55 = a[t= a[t44]]
if tif t55 > v goto B> v goto B33
if i >= j goto B6
a[a[tt22] = t] = t55
a[a[tt44] = t] = t33
goto Bgoto B22
tt1414 = a[t= a[t11]]
a[a[tt22] = t] = t1414
a[a[tt11] = t] = t33
B1
B2
B3
B4
B5 B6
Reduction in Strength
i = m - 1i = m - 1
j = nj = n
tt11 =4 * n=4 * n
v = a[tv = a[t11]]
i = i + 1i = i + 1
tt22 = 4 * i= 4 * i
tt33 = a[t= a[t22]]
if tif t33 < v goto B< v goto B22
j = j – 1j = j – 1
tt44 = 4 * j= 4 * j
tt55 = a[t= a[t44]]
if tif t55 > v goto B> v goto B33
if i >= j goto B6
a[a[tt22] = t] = t55
a[a[tt44] = t] = t33
goto Bgoto B22
tt1414 = a[t= a[t11]]
a[a[tt22] = t] = t1414
a[a[tt11] = t] = t33
B1
B2
B3
B4
B5 B6
Reduction in Strength
i = m - 1i = m - 1
j = nj = n
tt11 =4 * n=4 * n
v = a[tv = a[t11]]
tt22 = 4 * i= 4 * i
tt44 = 4 * j= 4 * j
tt22 = t= t22 + 4+ 4
tt33 = a[t= a[t22]]
if tif t33 < v goto B< v goto B22
tt44 = t= t44 - 4- 4
tt55 = a[t= a[t44]]
if tif t55 > v goto B> v goto B33
if i >= j goto B6
a[a[tt22] = t] = t55
a[a[tt44] = t] = t33
goto Bgoto B22
tt1414 = a[t= a[t11]]
a[a[tt22] = t] = t1414
a[a[tt11] = t] = t33
B1
B2
B3
B4
B5 B6

More Related Content

What's hot

Pipeline processing and space time diagram
Pipeline processing and space time diagramPipeline processing and space time diagram
Pipeline processing and space time diagramRahul Sharma
 
Lecture 21 problem reduction search ao star search
Lecture 21 problem reduction search ao star searchLecture 21 problem reduction search ao star search
Lecture 21 problem reduction search ao star searchHema Kashyap
 
Depth First Search, Breadth First Search and Best First Search
Depth First Search, Breadth First Search and Best First SearchDepth First Search, Breadth First Search and Best First Search
Depth First Search, Breadth First Search and Best First SearchAdri Jovin
 
Directed Acyclic Graph Representation of basic blocks
Directed Acyclic Graph Representation of basic blocksDirected Acyclic Graph Representation of basic blocks
Directed Acyclic Graph Representation of basic blocksMohammad Vaseem Akaram
 
Three address code In Compiler Design
Three address code In Compiler DesignThree address code In Compiler Design
Three address code In Compiler DesignShine Raj
 
Intermediate code- generation
Intermediate code- generationIntermediate code- generation
Intermediate code- generationrawan_z
 
Code generator
Code generatorCode generator
Code generatorTech_MX
 
Algorithms Lecture 2: Analysis of Algorithms I
Algorithms Lecture 2: Analysis of Algorithms IAlgorithms Lecture 2: Analysis of Algorithms I
Algorithms Lecture 2: Analysis of Algorithms IMohamed Loey
 
Expression evaluation
Expression evaluationExpression evaluation
Expression evaluationJeeSa Sultana
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notationsNikhil Sharma
 
Unit 2 application of stack
Unit 2  application of stack Unit 2  application of stack
Unit 2 application of stack LavanyaJ28
 
Bellman Ford's Algorithm
Bellman Ford's AlgorithmBellman Ford's Algorithm
Bellman Ford's AlgorithmTanmay Baranwal
 
Pointers, virtual function and polymorphism
Pointers, virtual function and polymorphismPointers, virtual function and polymorphism
Pointers, virtual function and polymorphismlalithambiga kamaraj
 

What's hot (20)

Pipeline processing and space time diagram
Pipeline processing and space time diagramPipeline processing and space time diagram
Pipeline processing and space time diagram
 
Lecture 21 problem reduction search ao star search
Lecture 21 problem reduction search ao star searchLecture 21 problem reduction search ao star search
Lecture 21 problem reduction search ao star search
 
Basic Block
Basic BlockBasic Block
Basic Block
 
Time complexity.ppt
Time complexity.pptTime complexity.ppt
Time complexity.ppt
 
Depth First Search, Breadth First Search and Best First Search
Depth First Search, Breadth First Search and Best First SearchDepth First Search, Breadth First Search and Best First Search
Depth First Search, Breadth First Search and Best First Search
 
Directed Acyclic Graph Representation of basic blocks
Directed Acyclic Graph Representation of basic blocksDirected Acyclic Graph Representation of basic blocks
Directed Acyclic Graph Representation of basic blocks
 
Code Optimization
Code OptimizationCode Optimization
Code Optimization
 
Three address code In Compiler Design
Three address code In Compiler DesignThree address code In Compiler Design
Three address code In Compiler Design
 
Intermediate code- generation
Intermediate code- generationIntermediate code- generation
Intermediate code- generation
 
Code generator
Code generatorCode generator
Code generator
 
Algorithms Lecture 2: Analysis of Algorithms I
Algorithms Lecture 2: Analysis of Algorithms IAlgorithms Lecture 2: Analysis of Algorithms I
Algorithms Lecture 2: Analysis of Algorithms I
 
Expression evaluation
Expression evaluationExpression evaluation
Expression evaluation
 
Bellman ford algorithm
Bellman ford algorithmBellman ford algorithm
Bellman ford algorithm
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
 
Code optimization
Code optimizationCode optimization
Code optimization
 
Unit 2 application of stack
Unit 2  application of stack Unit 2  application of stack
Unit 2 application of stack
 
Code generation
Code generationCode generation
Code generation
 
Bellman Ford's Algorithm
Bellman Ford's AlgorithmBellman Ford's Algorithm
Bellman Ford's Algorithm
 
A* Algorithm
A* AlgorithmA* Algorithm
A* Algorithm
 
Pointers, virtual function and polymorphism
Pointers, virtual function and polymorphismPointers, virtual function and polymorphism
Pointers, virtual function and polymorphism
 

Viewers also liked

01 intel v_tune_session_01
01 intel v_tune_session_0101 intel v_tune_session_01
01 intel v_tune_session_01Niit Care
 
Setmana cultural modernisme2013
Setmana cultural modernisme2013Setmana cultural modernisme2013
Setmana cultural modernisme2013kukies 33
 
Tucanitos explorando la naturaleza (Sensibilizar los niños y niñas, sobre la...
Tucanitos explorando la naturaleza (Sensibilizar  los niños y niñas, sobre la...Tucanitos explorando la naturaleza (Sensibilizar  los niños y niñas, sobre la...
Tucanitos explorando la naturaleza (Sensibilizar los niños y niñas, sobre la...CTeI Putumayo
 
Evaluation Question #1
Evaluation Question #1Evaluation Question #1
Evaluation Question #1alexsimpson95
 
Presentación diapositivas
Presentación  diapositivasPresentación  diapositivas
Presentación diapositivasjuandaprofe
 
брито – стрижено александров федор
брито – стрижено александров федорбрито – стрижено александров федор
брито – стрижено александров федорmorozovaeyu
 
Historia de la trigonometría
Historia de la trigonometríaHistoria de la trigonometría
Historia de la trigonometríaSonia Vanegas
 
Tic 06 Componentes del ordenador SOFTWARE
Tic 06 Componentes del ordenador SOFTWARETic 06 Componentes del ordenador SOFTWARE
Tic 06 Componentes del ordenador SOFTWARERosa Fernández
 
Acidosis Metabólica, Fisiopatología, Causas, Sintomas, y Caso clinico.
Acidosis Metabólica, Fisiopatología, Causas, Sintomas, y Caso clinico.Acidosis Metabólica, Fisiopatología, Causas, Sintomas, y Caso clinico.
Acidosis Metabólica, Fisiopatología, Causas, Sintomas, y Caso clinico.Yulianny Luque
 
o desafio de uma interação de qualidade na ea d
  o desafio de uma interação de qualidade na ea d  o desafio de uma interação de qualidade na ea d
o desafio de uma interação de qualidade na ea dFabio Pacheco
 

Viewers also liked (18)

01 intel v_tune_session_01
01 intel v_tune_session_0101 intel v_tune_session_01
01 intel v_tune_session_01
 
Intel VTune
Intel VTuneIntel VTune
Intel VTune
 
Setmana cultural modernisme2013
Setmana cultural modernisme2013Setmana cultural modernisme2013
Setmana cultural modernisme2013
 
Tucanitos explorando la naturaleza (Sensibilizar los niños y niñas, sobre la...
Tucanitos explorando la naturaleza (Sensibilizar  los niños y niñas, sobre la...Tucanitos explorando la naturaleza (Sensibilizar  los niños y niñas, sobre la...
Tucanitos explorando la naturaleza (Sensibilizar los niños y niñas, sobre la...
 
Evaluation Question #1
Evaluation Question #1Evaluation Question #1
Evaluation Question #1
 
Presentación diapositivas
Presentación  diapositivasPresentación  diapositivas
Presentación diapositivas
 
El rio sinu y nuestro tesoro
El rio sinu y nuestro tesoroEl rio sinu y nuestro tesoro
El rio sinu y nuestro tesoro
 
брито – стрижено александров федор
брито – стрижено александров федорбрито – стрижено александров федор
брито – стрижено александров федор
 
Historia de la trigonometría
Historia de la trigonometríaHistoria de la trigonometría
Historia de la trigonometría
 
amines
amines amines
amines
 
Tic 06 Componentes del ordenador SOFTWARE
Tic 06 Componentes del ordenador SOFTWARETic 06 Componentes del ordenador SOFTWARE
Tic 06 Componentes del ordenador SOFTWARE
 
Vol1
Vol1Vol1
Vol1
 
Ajs 4 a
Ajs 4 aAjs 4 a
Ajs 4 a
 
Acidosis Metabólica, Fisiopatología, Causas, Sintomas, y Caso clinico.
Acidosis Metabólica, Fisiopatología, Causas, Sintomas, y Caso clinico.Acidosis Metabólica, Fisiopatología, Causas, Sintomas, y Caso clinico.
Acidosis Metabólica, Fisiopatología, Causas, Sintomas, y Caso clinico.
 
Ajs 4 b
Ajs 4 bAjs 4 b
Ajs 4 b
 
Ajs 1 b
Ajs 1 bAjs 1 b
Ajs 1 b
 
o desafio de uma interação de qualidade na ea d
  o desafio de uma interação de qualidade na ea d  o desafio de uma interação de qualidade na ea d
o desafio de uma interação de qualidade na ea d
 
El gran hermano digital
El gran hermano digitalEl gran hermano digital
El gran hermano digital
 

Similar to code optimization 1...code optimization-1221849738688969-9

code optimization
code optimizationcode optimization
code optimizationguest9f8315
 
toaz.info-2019-modul-latihan-matematik-tingkatan-3-pt3-pr_ce334399241c80fe596...
toaz.info-2019-modul-latihan-matematik-tingkatan-3-pt3-pr_ce334399241c80fe596...toaz.info-2019-modul-latihan-matematik-tingkatan-3-pt3-pr_ce334399241c80fe596...
toaz.info-2019-modul-latihan-matematik-tingkatan-3-pt3-pr_ce334399241c80fe596...NORAINIBINTISEMANMoe
 
The Inner Secrets of Compilers
The Inner Secrets of CompilersThe Inner Secrets of Compilers
The Inner Secrets of CompilersIT MegaMeet
 
Online partial evaluation
Online partial evaluationOnline partial evaluation
Online partial evaluationEelco Visser
 
CS540-2-lecture11 - Copy.ppt
CS540-2-lecture11 - Copy.pptCS540-2-lecture11 - Copy.ppt
CS540-2-lecture11 - Copy.pptssuser0be977
 
chapter1.ppt
chapter1.pptchapter1.ppt
chapter1.pptebinazer1
 
Solución guía n°1 operaciones combinadas
Solución guía n°1 operaciones combinadasSolución guía n°1 operaciones combinadas
Solución guía n°1 operaciones combinadasFrancisco Gaete Garrido
 
System dynamics 3rd edition palm solutions manual
System dynamics 3rd edition palm solutions manualSystem dynamics 3rd edition palm solutions manual
System dynamics 3rd edition palm solutions manualSextonMales
 
Fishers linear discriminant for dimensionality reduction.
Fishers linear discriminant for dimensionality reduction.Fishers linear discriminant for dimensionality reduction.
Fishers linear discriminant for dimensionality reduction.Nurul Amin Choudhury
 
Compiler Optimization Presentation
Compiler Optimization PresentationCompiler Optimization Presentation
Compiler Optimization Presentation19magnet
 
05 lcd slides 1 - CPU SCHEDULING (Powerpoint)
05 lcd slides 1 - CPU SCHEDULING (Powerpoint)05 lcd slides 1 - CPU SCHEDULING (Powerpoint)
05 lcd slides 1 - CPU SCHEDULING (Powerpoint)Anne Lee
 
quantum chemistry on quantum computer handson by Q# (2019/8/4@MDR Hongo, Tokyo)
quantum chemistry on quantum computer handson by Q# (2019/8/4@MDR Hongo, Tokyo)quantum chemistry on quantum computer handson by Q# (2019/8/4@MDR Hongo, Tokyo)
quantum chemistry on quantum computer handson by Q# (2019/8/4@MDR Hongo, Tokyo)Maho Nakata
 
Goal Programming
Goal ProgrammingGoal Programming
Goal ProgrammingEvren E
 

Similar to code optimization 1...code optimization-1221849738688969-9 (20)

code optimization
code optimizationcode optimization
code optimization
 
Slides13.pdf
Slides13.pdfSlides13.pdf
Slides13.pdf
 
toaz.info-2019-modul-latihan-matematik-tingkatan-3-pt3-pr_ce334399241c80fe596...
toaz.info-2019-modul-latihan-matematik-tingkatan-3-pt3-pr_ce334399241c80fe596...toaz.info-2019-modul-latihan-matematik-tingkatan-3-pt3-pr_ce334399241c80fe596...
toaz.info-2019-modul-latihan-matematik-tingkatan-3-pt3-pr_ce334399241c80fe596...
 
Lec38
Lec38Lec38
Lec38
 
The Inner Secrets of Compilers
The Inner Secrets of CompilersThe Inner Secrets of Compilers
The Inner Secrets of Compilers
 
14 recursion
14 recursion14 recursion
14 recursion
 
Online partial evaluation
Online partial evaluationOnline partial evaluation
Online partial evaluation
 
HIDRAULICA DE CANALES
HIDRAULICA DE CANALESHIDRAULICA DE CANALES
HIDRAULICA DE CANALES
 
TP3.pdf
TP3.pdfTP3.pdf
TP3.pdf
 
Code Optimization.ppt
Code Optimization.pptCode Optimization.ppt
Code Optimization.ppt
 
CS540-2-lecture11 - Copy.ppt
CS540-2-lecture11 - Copy.pptCS540-2-lecture11 - Copy.ppt
CS540-2-lecture11 - Copy.ppt
 
chapter1.ppt
chapter1.pptchapter1.ppt
chapter1.ppt
 
Solución guía n°1 operaciones combinadas
Solución guía n°1 operaciones combinadasSolución guía n°1 operaciones combinadas
Solución guía n°1 operaciones combinadas
 
Recursion.pptx
Recursion.pptxRecursion.pptx
Recursion.pptx
 
System dynamics 3rd edition palm solutions manual
System dynamics 3rd edition palm solutions manualSystem dynamics 3rd edition palm solutions manual
System dynamics 3rd edition palm solutions manual
 
Fishers linear discriminant for dimensionality reduction.
Fishers linear discriminant for dimensionality reduction.Fishers linear discriminant for dimensionality reduction.
Fishers linear discriminant for dimensionality reduction.
 
Compiler Optimization Presentation
Compiler Optimization PresentationCompiler Optimization Presentation
Compiler Optimization Presentation
 
05 lcd slides 1 - CPU SCHEDULING (Powerpoint)
05 lcd slides 1 - CPU SCHEDULING (Powerpoint)05 lcd slides 1 - CPU SCHEDULING (Powerpoint)
05 lcd slides 1 - CPU SCHEDULING (Powerpoint)
 
quantum chemistry on quantum computer handson by Q# (2019/8/4@MDR Hongo, Tokyo)
quantum chemistry on quantum computer handson by Q# (2019/8/4@MDR Hongo, Tokyo)quantum chemistry on quantum computer handson by Q# (2019/8/4@MDR Hongo, Tokyo)
quantum chemistry on quantum computer handson by Q# (2019/8/4@MDR Hongo, Tokyo)
 
Goal Programming
Goal ProgrammingGoal Programming
Goal Programming
 

Recently uploaded

College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingrknatarajan
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...RajaP95
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Christo Ananth
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 

Recently uploaded (20)

College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 

code optimization 1...code optimization-1221849738688969-9

  • 1. CODE OPTIMIZATION PRSENTED BY: SANJEEV KUMAR…… DEPT:-IT. ASSAM UNIVERSITY ,SILCHAR
  • 2. Design Of a Compiler Lexical Analysis Syntax Analysis Intermediate Code Generation Code Generation Code Optimization Table Mgmt Routine Error Handling Routine Source code Object code
  • 3. What is optimization?  In computing, optimization is the process of modifying a system to make some aspect of it work more efficiently or use fewer resources. For instance, a computer program may be optimized so that it executes more rapidly, or is capable of operating with less memory storage or other resources, or draw less power. The system may be a single computer program, a collection of computers or even an entire network such as the internet.
  • 4.
  • 5. Levels' of optimization Optimization can occur at a number of 'levels':  Design level At the highest level, the design may be optimized to make best use of the available resources. The implementation of this design will benefit from the use of suitable efficient algorithms and the implementation of these algorithms will benefit from writing good quality code. The architectural design of a system overwhelmingly affects its performance. The choice of algorithm affects efficiency more than any other item of the design.  Compile level Use of an optimizing compiler tends to ensure that the executable program is optimized at least as much as the compiler can predict.
  • 6.  Assembly level At the lowest level, writing code using an Assembly language designed for a particular hardware platform will normally produce the most efficient code since the programmer can take advantage of the full repertoire of machine instructions. The operating systems of most machines has been traditionally written in Assembler code for this reason.  Runtime Just In Time Compiler and assembler programmers are able to perform runtime optimization.
  • 7. When to optimize ? Optimization is often performed at the end of the development stage since it • reduces readability • adds code that is used to improve the performance.
  • 8. Criteria For optimization An optimization must preserve the meaning of a program : -Cannot change the output produced for any input -Can not introduce an error optimization should, on average, speed up programs Transformation should be worth the effort
  • 9. Improvements can be made at various phases: Source Code: -Algorithms transformations can produce spectacular improvements -Profiling can be helpful to focus a programmer’s attention on important code. Intermediate Code: -Compiler can improve loops, procedure calls and address calculations -Typically only optimizing compilers include this phase Target Code: -Compilers can use registers efficiently -Peephole transformation can be applied
  • 10. Types of Code optimization  Common Sub-expression Removal  Dead Code Optimization  Loop Optimization
  • 11. Common Sub expression elimination Common Sub expression elimination is a optimization that searches for instances of identical expressions (i.e they all evaluate the same value), and analyses whether it is worthwhile replacing with a single variable holding the computed value. a=b * c + g d=b * c * d temp=b * c a=temp + g d=temp * d
  • 12. Dead Code elimination is a compiler optimization that removes code that does not affect a program. Removing such code has two benefits It shrinks program size, an important consideration in some contexts. It lets the running program avoid executing irrelevant operations, which reduces its running time. Dead Code elimination is of two types Unreachable Code Redundant statement Dead code Optimization:
  • 13. Unreachable Code In Computer Programming, Unreachable Code or dead code is code that exists in the source code of a program but can never be executed. Program Code If (a>b) m=a elseif (a<b) m=b elseif (a==b) m=0 else m=-1 Optimized Code If (a>b) m=a elseif (a<b) m=b else m=0
  • 14. Redundant Code Redundant Code is code that is executed but has no effect on the output from a program main(){ int a,b,c,r; a=5; b=6; c=a + b; r=2; r++; printf(“%d”,c); } Adding time & space complexity
  • 15. Loop optimization Loop optimization plays an important role in improving the performance of the source code by reducing overheads associated with executing loops. Loop Optimization can be done by removing: • Loop invariant • Induction variables
  • 16. Loop Invariant i = 1 s= 0 do{ s= s + i a =5 i = i + 1 { while (i < =n) i = 1 s= 0 a =5 do{ s= s + i i = i + 1 { while (i < =n) Bringing a=5 outside the do while loop, is called code motion.
  • 17. Induction variables i = 1 s= 0 S1=0 S2=0 while (i < =n) { s= s + a[ i ] t1 = i * 4 s= s + b[ t1 ] t2 = t1 +2 s2= s2 + c[ t2 ] i = i + 1 } i = 1 s= 0 S1=0 S2=0 t2=0 while (i < =n) { s= s + a[ i ] t1 = t1+ 4 s= s + b[ t1 ] s2= s2 + c[t1 +2 ] i = i + 1 } t1,t2 are induction variables. i is inducing t1 and t1 is inducing t2 “+” replaced “ * ”, t1 was made independent of i
  • 18.
  • 19.
  • 20.
  • 21.
  • 22. Common Sub-expression Removal  It is used to remove redundant computations which usually improves the execution time of a program.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29. Three Address Code of Quick Sort i = m - 1i = m - 1 j = nj = n tt11 =4 * n=4 * n v = a[tv = a[t11]] i = i + 1i = i + 1 tt22 = 4 * i= 4 * i tt33 = a[t= a[t22]] if tif t33 < v goto (5)< v goto (5) j = j – 1j = j – 1 tt44 = 4 * j= 4 * j tt55 = a[t= a[t44]] if tif t55 > v goto (9)> v goto (9) if i >= j goto (23)if i >= j goto (23) tt66 = 4 * i= 4 * i x = a[tx = a[t66]] 11 22 33 44 55 66 77 88 99 1010 1111 1212 1313 1414 1515 tt77 = 4 * I= 4 * I tt88 = 4 * j= 4 * j tt99 = a[t= a[t88]] a[ta[t77] = t] = t99 tt1010 = 4 * j= 4 * j a[ta[t1010] = x] = x goto (5)goto (5) tt1111 = 4 * I= 4 * I x = a[tx = a[t1111]] tt1212 = 4 * i= 4 * i tt1313 = 4 * n= 4 * n tt1414 = a[t= a[t1313]] a[ta[t1212] = t] = t1414 tt1515 = 4 * n= 4 * n a[ta[t ] = x] = x 1616 1717 1818 1919 2020 2121 2222 2323 2424 2525 2626 2727 2828 2929 3030
  • 30. Find The Basic Block i = m - 1i = m - 1 j = nj = n tt11 =4 * n=4 * n v = a[tv = a[t11]] i = i + 1i = i + 1 tt22 = 4 * i= 4 * i tt33 = a[t= a[t22]] if tif t33 < v goto (5)< v goto (5) j = j – 1j = j – 1 tt44 = 4 * j= 4 * j tt55 = a[t= a[t44]] if tif t55 > v goto (9)> v goto (9) if i >= j goto (23)if i >= j goto (23) tt66 = 4 * i= 4 * i x = a[tx = a[t66]] 11 22 33 44 55 66 77 88 99 1010 1111 1212 1313 1414 1515 tt77 = 4 * I= 4 * I tt88 = 4 * j= 4 * j tt99 = a[t= a[t88]] a[ta[t77] = t] = t99 tt1010 = 4 * j= 4 * j a[ta[t1010] = x] = x goto (5)goto (5) tt1111 = 4 * i= 4 * i x = a[tx = a[t1111]] tt1212 = 4 * i= 4 * i tt1313 = 4 * n= 4 * n tt1414 = a[t= a[t1313]] a[ta[t1212] = t] = t1414 tt1515 = 4 * n= 4 * n a[ta[t ] = x] = x 1616 1717 1818 1919 2020 2121 2222 2323 2424 2525 2626 2727 2828 2929 3030
  • 31. Flow Graph i = m - 1i = m - 1 j = nj = n tt11 =4 * n=4 * n v = a[tv = a[t11]] i = i + 1i = i + 1 tt22 = 4 * i= 4 * i tt33 = a[t= a[t22]] if tif t33 < v goto B< v goto B22 j = j – 1j = j – 1 tt44 = 4 * j= 4 * j tt55 = a[t= a[t44]] if tif t55 > v goto B> v goto B33 if i >= j goto B6 tt66 = 4 * i= 4 * i x = a[tx = a[t66]] tt77 = 4 * i= 4 * i tt88 = 4 * j= 4 * j tt99 = a[t= a[t88]] a[ta[t77] = t] = t99 tt1010 = 4 * j= 4 * j a[ta[t1010] = x] = x goto Bgoto B22 tt1111 = 4 * i= 4 * i x = a[tx = a[t1111]] tt1212 = 4 * i= 4 * i tt1313 = 4 * n= 4 * n tt1414 = a[t= a[t1313]] a[ta[t1212] = t] = t1414 tt1515 = 4 * n= 4 * n a[ta[t1515] = x] = x B1 B2 B3 B4 B5 B6
  • 32. Common Subexpression Elimination i = m - 1i = m - 1 j = nj = n tt11 =4 * n=4 * n v = a[tv = a[t11]] i = i + 1i = i + 1 tt22 = 4 * i= 4 * i tt33 = a[t= a[t22]] if tif t33 < v goto B< v goto B22 j = j – 1j = j – 1 tt44 = 4 * j= 4 * j tt55 = a[t= a[t44]] if tif t55 > v goto B> v goto B33 if i >= j goto B6 tt66 = 4 * i= 4 * i x = a[tx = a[t66]] tt77 = 4 * i= 4 * i tt88 = 4 * j= 4 * j tt99 = a[t= a[t88]] a[ta[t77] = t] = t99 tt1010 = 4 * j= 4 * j a[ta[t1010] = x] = x goto Bgoto B22 tt1111 = 4 * i= 4 * i x = a[tx = a[t1111]] tt1212 = 4 * i= 4 * i tt1313 = 4 * n= 4 * n tt1414 = a[t= a[t1313]] a[ta[t1212] = t] = t1414 tt1515 = 4 * n= 4 * n a[ta[t1515] = x] = x B1 B2 B3 B4 B5 B6
  • 33. Common Subexpression Elimination i = m - 1i = m - 1 j = nj = n tt11 =4 * n=4 * n v = a[tv = a[t11]] i = i + 1i = i + 1 tt22 = 4 * i= 4 * i tt33 = a[t= a[t22]] if tif t33 < v goto B< v goto B22 j = j – 1j = j – 1 tt44 = 4 * j= 4 * j tt55 = a[t= a[t44]] if tif t55 > v goto B> v goto B33 if i >= j goto B6 tt66 = 4 * i= 4 * i x = a[tx = a[t66]] tt88 = 4 * j= 4 * j tt99 = a[t= a[t88]] a[a[tt66] = t] = t99 tt1010 = 4 *= 4 * jj a[ta[t1010] = x] = x goto Bgoto B22 tt1111 = 4 * i= 4 * i x = a[tx = a[t1111]] tt1212 = 4 * i= 4 * i tt1313 = 4 * n= 4 * n tt1414 = a[t= a[t1313]] a[ta[t1212] = t] = t1414 tt1515 = 4 * n= 4 * n a[ta[t1515] = x] = x B1 B2 B3 B4 B5 B6
  • 34. Common Subexpression Elimination i = m - 1i = m - 1 j = nj = n tt11 =4 * n=4 * n v = a[tv = a[t11]] i = i + 1i = i + 1 tt22 = 4 * i= 4 * i tt33 = a[t= a[t22]] if tif t33 < v goto B< v goto B22 j = j – 1j = j – 1 tt44 = 4 * j= 4 * j tt55 = a[t= a[t44]] if tif t55 > v goto B> v goto B33 if i >= j goto B6 tt66 = 4 * i= 4 * i x = a[tx = a[t66]] tt88 = 4 * j= 4 * j tt99 = a[t= a[t88]] a[a[tt66] = t] = t99 a[a[tt88] = x] = x goto Bgoto B22 tt1111 = 4 *i= 4 *i x = a[tx = a[t1111]] tt1212 = 4 * i= 4 * i tt1313 = 4 * n= 4 * n tt1414 = a[t= a[t1313]] a[ta[t1212] = t] = t1414 tt1515 = 4 * n= 4 * n a[ta[t1515] = x] = x B1 B2 B3 B4 B5 B6
  • 35. Common Subexpression Elimination i = m - 1i = m - 1 j = nj = n tt11 =4 * n=4 * n v = a[tv = a[t11]] i = i + 1i = i + 1 tt22 = 4 * i= 4 * i tt33 = a[t= a[t22]] if tif t33 < v goto B< v goto B22 j = j – 1j = j – 1 tt44 = 4 * j= 4 * j tt55 = a[t= a[t44]] if tif t55 > v goto B> v goto B33 if i >= j goto B6 tt66 = 4 * i= 4 * i x = a[tx = a[t66]] tt88 = 4 * j= 4 * j tt99 = a[t= a[t88]] a[a[tt66] = t] = t99 a[a[tt88] = x] = x goto Bgoto B22 tt1111 = 4 * i= 4 * i x = a[tx = a[t1111]] tt1212 = 4 * i= 4 * i tt1313 = 4 * n= 4 * n tt1414 = a[t= a[t1313]] a[ta[t1212] = t] = t1414 tt1515 = 4 * n= 4 * n a[ta[t1515] = x] = x B1 B2 B3 B4 B5 B6
  • 36. Common Subexpression Elimination i = m - 1i = m - 1 j = nj = n tt11 =4 * n=4 * n v = a[tv = a[t11]] i = i + 1i = i + 1 tt22 = 4 * i= 4 * i tt33 = a[t= a[t22]] if tif t33 < v goto B< v goto B22 j = j – 1j = j – 1 tt44 = 4 * j= 4 * j tt55 = a[t= a[t44]] if tif t55 > v goto B> v goto B33 if i >= j goto B6 tt66 = 4 * i= 4 * i x = a[tx = a[t66]] tt88 = 4 * j= 4 * j tt99 = a[t= a[t88]] a[a[tt66] = t] = t99 a[a[tt88] = x] = x goto Bgoto B22 tt1111 = 4 * i= 4 * i x = a[tx = a[t1111]] tt1313 = 4 * n= 4 * n tt1414 = a[t= a[t1313]] a[a[tt1111] = t] = t1414 tt1515 = 4 * n= 4 * n a[ta[t1515] = x] = x B1 B2 B3 B4 B5 B6
  • 37. Common Subexpression Elimination i = m - 1i = m - 1 j = nj = n tt11 =4 * n=4 * n v = a[tv = a[t11]] i = i + 1i = i + 1 tt22 = 4 * i= 4 * i tt33 = a[t= a[t22]] if tif t33 < v goto B< v goto B22 j = j – 1j = j – 1 tt44 = 4 * j= 4 * j tt55 = a[t= a[t44]] if tif t55 > v goto B> v goto B33 if i >= j goto B6 tt66 = 4 * i= 4 * i x = a[tx = a[t66]] tt88 = 4 * j= 4 * j tt99 = a[t= a[t88]] a[a[tt66] = t] = t99 a[a[tt88] = x] = x goto Bgoto B22 tt1111 = 4 * i= 4 * i x = a[tx = a[t1111]] tt1313 = 4 * n= 4 * n tt1414 = a[t= a[t1313]] a[a[tt1111] = t] = t1414 a[a[tt1313] = x] = x B1 B2 B3 B4 B5 B6
  • 38. Common Subexpression Elimination i = m - 1i = m - 1 j = nj = n tt11 =4 * n=4 * n v = a[tv = a[t11]] i = i + 1i = i + 1 tt22 = 4 * i= 4 * i tt33 = a[t= a[t22]] if tif t33 < v goto B< v goto B22 j = j – 1j = j – 1 tt44 = 4 * j= 4 * j tt55 = a[t= a[t44]] if tif t55 > v goto B> v goto B33 if i >= j goto B6 tt66 = 4 * i= 4 * i x = a[tx = a[t66]] tt88 = 4 * j= 4 * j tt99 = a[t= a[t88]] a[a[tt66] = t] = t99 a[a[tt88] = x] = x goto Bgoto B22 tt1111 = 4 * i= 4 * i x = a[tx = a[t1111]] tt1313 = 4 * n= 4 * n tt1414 = a[t= a[t1313]] a[a[tt1111] = t] = t1414 a[a[tt1313] = x] = x B1 B2 B3 B4 B5 B6
  • 39. Common Subexpression Elimination i = m - 1i = m - 1 j = nj = n tt11 =4 * n=4 * n v = a[tv = a[t11]] i = i + 1i = i + 1 tt22 = 4 * i= 4 * i tt33 = a[t= a[t22]] if tif t33 < v goto B< v goto B22 j = j – 1j = j – 1 tt44 = 4 * j= 4 * j tt55 = a[t= a[t44]] if tif t55 > v goto B> v goto B33 if i >= j goto B6 x = a[x = a[tt22]] tt88 = 4 * j= 4 * j tt99 = a[t= a[t88]] a[a[tt22] = t] = t99 a[a[tt88] = x] = x goto Bgoto B22 tt1111 = 4 * i= 4 * i x = a[tx = a[t1111]] tt1313 = 4 * n= 4 * n tt1414 = a[t= a[t1313]] a[a[tt1111] = t] = t1414 a[a[tt1313] = x] = x B1 B2 B3 B4 B5 B6
  • 40. Common Subexpression Elimination i = m - 1i = m - 1 j = nj = n tt11 =4 * n=4 * n v = a[tv = a[t11]] i = i + 1i = i + 1 tt22 = 4 * i= 4 * i tt33 = a[t= a[t22]] if tif t33 < v goto B< v goto B22 j = j – 1j = j – 1 tt44 = 4 * j= 4 * j tt55 = a[t= a[t44]] if tif t55 > v goto B> v goto B33 if i >= j goto B6 x = tx = t33 tt88 = 4 * j= 4 * j tt99 = a[t= a[t88]] a[a[tt22] = t] = t99 a[a[tt88] = x] = x goto Bgoto B22 tt1111 = 4 * i= 4 * i x = a[tx = a[t1111]] tt1313 = 4 * n= 4 * n tt1414 = a[t= a[t1313]] a[a[tt1111] = t] = t1414 a[a[tt1313] = x] = x B1 B2 B3 B4 B5 B6
  • 41. Common Subexpression Elimination i = m - 1i = m - 1 j = nj = n tt11 =4 * n=4 * n v = a[tv = a[t11]] i = i + 1i = i + 1 tt22 = 4 * i= 4 * i tt33 = a[t= a[t22]] if tif t33 < v goto B< v goto B22 j = j – 1j = j – 1 tt44 = 4 * j= 4 * j tt55 = a[t= a[t44]] if tif t55 > v goto B> v goto B33 if i >= j goto B6 x = tx = t33 a[a[tt22] = t] = t55 a[a[tt44] = x] = x goto Bgoto B22 tt1111 = 4 * i= 4 * i x = a[tx = a[t1111]] tt1313 = 4 * n= 4 * n tt1414 = a[t= a[t1313]] a[a[tt1111] = t] = t1414 a[a[tt1313] = x] = x B1 B2 B3 B4 B5 B6
  • 42. Common Subexpression Elimination i = m - 1i = m - 1 j = nj = n tt11 =4 * n=4 * n v = a[tv = a[t11]] i = i + 1i = i + 1 tt22 = 4 * i= 4 * i tt33 = a[t= a[t22]] if tif t33 < v goto B< v goto B22 j = j – 1j = j – 1 tt44 = 4 * j= 4 * j tt55 = a[t= a[t44]] if tif t55 > v goto B> v goto B33 if i >= j goto B6 x = tx = t33 a[a[tt22] = t] = t55 a[a[tt44] = x] = x goto Bgoto B22 x = tx = t33 tt1414 = a[t= a[t11]] a[a[tt22] = t] = t1414 a[a[tt11] = x] = x B1 B2 B3 B4 B5 B6 Similarly for B6
  • 43. Dead Code Elimination i = m - 1i = m - 1 j = nj = n tt11 =4 * n=4 * n v = a[tv = a[t11]] i = i + 1i = i + 1 tt22 = 4 * i= 4 * i tt33 = a[t= a[t22]] if tif t33 < v goto B< v goto B22 j = j – 1j = j – 1 tt44 = 4 * j= 4 * j tt55 = a[t= a[t44]] if tif t55 > v goto B> v goto B33 if i >= j goto B6 x = tx = t33 a[a[tt22] = t] = t55 a[a[tt44] = x] = x goto Bgoto B22 x = tx = t33 tt1414 = a[t= a[t11]] a[a[tt22] = t] = t1414 a[a[tt11] = x] = x B1 B2 B3 B4 B5 B6
  • 44. Dead Code Elimination i = m - 1i = m - 1 j = nj = n tt11 =4 * n=4 * n v = a[tv = a[t11]] i = i + 1i = i + 1 tt22 = 4 * i= 4 * i tt33 = a[t= a[t22]] if tif t33 < v goto B< v goto B22 j = j – 1j = j – 1 tt44 = 4 * j= 4 * j tt55 = a[t= a[t44]] if tif t55 > v goto B> v goto B33 if i >= j goto B6 a[a[tt22] = t] = t55 a[a[tt44] = t] = t33 goto Bgoto B22 tt1414 = a[t= a[t11]] a[a[tt22] = t] = t1414 a[a[tt11] = t] = t33 B1 B2 B3 B4 B5 B6
  • 45. Reduction in Strength i = m - 1i = m - 1 j = nj = n tt11 =4 * n=4 * n v = a[tv = a[t11]] i = i + 1i = i + 1 tt22 = 4 * i= 4 * i tt33 = a[t= a[t22]] if tif t33 < v goto B< v goto B22 j = j – 1j = j – 1 tt44 = 4 * j= 4 * j tt55 = a[t= a[t44]] if tif t55 > v goto B> v goto B33 if i >= j goto B6 a[a[tt22] = t] = t55 a[a[tt44] = t] = t33 goto Bgoto B22 tt1414 = a[t= a[t11]] a[a[tt22] = t] = t1414 a[a[tt11] = t] = t33 B1 B2 B3 B4 B5 B6
  • 46. Reduction in Strength i = m - 1i = m - 1 j = nj = n tt11 =4 * n=4 * n v = a[tv = a[t11]] tt22 = 4 * i= 4 * i tt44 = 4 * j= 4 * j tt22 = t= t22 + 4+ 4 tt33 = a[t= a[t22]] if tif t33 < v goto B< v goto B22 tt44 = t= t44 - 4- 4 tt55 = a[t= a[t44]] if tif t55 > v goto B> v goto B33 if i >= j goto B6 a[a[tt22] = t] = t55 a[a[tt44] = t] = t33 goto Bgoto B22 tt1414 = a[t= a[t11]] a[a[tt22] = t] = t1414 a[a[tt11] = t] = t33 B1 B2 B3 B4 B5 B6