Unit 5
Unit 5
(ov)
Mov C, R Cost3 more e fo m memoy
A DD anel ad d
Rj, Ri
Kegis Terand dddus Desttplarns
he Code qenenaluon algontum uses deaciptors
eep rack egiuker Contents and Addresse
nan es
Page No.
Mov b(R), R.
a: b Mov b a (R).
Expt. No. ********e Page N0.
Mov y Ro
Ann z Ro
ifxsogaloz-
Noy RD, x
CAz.
ttr
Emologues d U Ba3e Plock
statementa'b+C4
aule (ic=1o)
* * * * * * * * * * * * * * * * * * * * * * * *
Page No. .
Expt. No...
***** ***.
*****
AcCenalivng o algoilkd
mol::0
Slatenaeui u a laale
3 4tiL hy n b la)
4 t 2 allaLonuputaluu alJ) ktatemant 3 uOat
h yu l e i l h )
Blatk
ta[L_
t3(A
6 6 tublta
8- prdtts
12 iAslo gatel3)
Flow aph
in uch the
dlörecled graph
A Fou graph a a
basibbcks
3 addess Code as
T
prod:0 Block Br: the
inital Block
3 E 4+1
4. ta a l t . ti:4*
5 t3: 4* .
E3 4 * i
6 Ey blts
y: b[J
7. ts = ta * t4 Es t2 *t4
8 tb prod t E'pmd +t5
Prod t 6
E7:i+
A E1
:-E7
if isalo gotol3)
2 i = lo golo (38)
F.loo aph
Loop Loop
Lo op is a Colleduon nodes in the feo qvap
Suth tht ()All Suh nodes ame sbrongly Connecled. Tus
Mens always there is a palh 3om any ode a
othen node oitin hat '
Expt. No. Page No...
tu iaternoolialh. Code
tanget odde. Used t Improve
Could sun faster
aslen
hat the output ef ue pYogvam
and take se less spa te or ba
Can be Lotally
oleue lotally basie
lhe optimizáuon Same ba
is appliee) ou
h e
the S ame
tthe tranfomakion is olone lbcally
is done loca
C.
Transfomation
block fhen h a t Kind e
unCuon presenving uomallov
wich Canpilo
Compileen
a
in
ihee ae a numben e waus the function it t
The funion
a o tBrout changing
Can Tmpove
Can proqam
paqalion
sub expression diminatien, opi POP
Computes. lommo n ane
ane
ommen
(om
Elminaluem
an
en
8ub expression
The Commen
eol
Cenmputeol previousy
previousy
w ih
wuith uu lomput
n he program olo not get changed
Tepeateolly Sul expresstou
ott used
sed inateaol
nsteaol
the opeanos is
hen i
Then
Suth sub
expesion
at
a t all then result o
relomputing
eath ume
eaul E1:=b *C
t2 a-Ei
t= bc Coole
Optimi'zoo
t 3 = t 2 +E)
t a-ti
t3 btC Ase on
O ne
mean
se
' e a t3 propagauon
pagatiovm:
Vaniable 2A
(t) Lopy Ao br e
tor xampe:
exampe
anolher.
anothor.
ulead ok OYA X* Y¥ T
Vaiable
Natiale popagalon
optimizaien usin
e
a oleuS amea =pit r*"
Ceun be olove
Mexe Vaualsle x s eli'i nated
tDead Coode Eliminetion
A Vaiable sad be ve iu a
pog
PTo Tam
Hhue
Hhese ueless
weless ugs roma
rom«
Hungs
eliminalinq
Quy wthen usesS. By
ue Cbole wilqet optimi zed.
Gocle,
Ca-b)
a=b
bC
Tetwn
Tttwtn b;
C O,
b en self. 2*3.
X
Fov examp le
Iuial Cocle
X6
Opbimized o ole :
Zend
(Loop qplimizatin the
The n
nnne
ent lotps, pro9ram
loops, p rgrama
Unnin Time ob
n
linme
oops, espeially
nIn bop l u m e . he unning
ime.
bulk o tuein t l e nwmben O
h e numbe
o Spend te
be tmpro ved eveu
a pmgram may es deuveas eo,
intuttions
an Ane leop outsi de t t a t
outside
amownt e Code
lode
nureae te.
we
Vavfalle elimualuon
innereop,
fom tie
)Lnouttien tie Loop
Vauables Leopp L f
t Yeplate Fnducten Variable Vaxiable
Appiod Called an
a n
Fnducten
T+
I t sis eitrer
etex
is me.
linme.
AYaia ble x
Vcoiable gets thanged
b Some
eveu
evey
nstaut
tnstaunE
the
The Yale of by
Some
incremented
values and
or Te
detremented
B (ode,
Ttu
lotked sta hat iu,
Exomple:-|:= i+ E a n e in
incremenled
i gel
shen value o
aCt intemenlad hy 4.
t a 4 i o g0to Bi k I t e n E gets
atlo induitiow Vari
Hence t4 are
Cperators
and
low
uen en strength opena lor
sbengh opetator by
by
h i g he redutuen Tee huque. s b e n g t h reduiuon
meclutlon
Stength t
Caled a
appying sben
be elone by
ptimizatuon
Can
Cau be epla cad b
streg th
kecnigue
where higke
Lowen 3bvength opetaloYs Aller cptinu zaueu
Beone optiu zalion lemp 7 ;
i14) f
For (i:1 i<1o ;
Sum i emp lemp+7
).a"; Sum)
point f (" Sum Temp;
Puint f ( 7 d " , Sum);
Basic Blotkhs
Bletks
Opumi alun
tle basie
Optimi zauon pYo
COsS Can be aPplieol cu
ang e
clavge
don't uead t s
Blocks. wi le optimi zation,
Ceptcd
Ttiu blot
byTtuu k
lotck
expresSiovs
Sek op imizaleis
ophimizaliou
basic Blotk
bloek
ane
usD y pes
heoa
Yelloos
These ae a
as m a
aufemnalwn
n e m n a l u w r n s
Presermn9
SOuttwe
Ci)
i ) Alaehrit vaudommalu
Imansomatona maton
a nsfo manidomaluon on
presering
stmuelwre
he p
TheP
ima
as fotloos
blocks
bastc elimt n á l m
Sub- expression
Common
Dcad Coode ellminauon
Renamin tu
lempolu Vastialsles
Vaialles
slaleme
inolepenolent aodj a cent
Tuwo
Intenchonge
Coe Hovement
Strength leouuion
a
DAG
Ho
rans mmation
aion
pYesoing bra is Co
C ou
tu ee
tu te
tess
l
/he
h e
stmeture
a DAG is
DG tnansfomna
er me
m ea
anns
s
Tak tion
bions tnansfonma
fomalien. abore Saiol
Saiol
Based Tranu t
abore
Bock
Rhen
tRen
he
the Basic
for
tor
Cen e appued. oleatad by
b
olelerled
Sub expvessiom
Can be ea
ea
baate block
Cornmo
e omespemolung bas
ehseving he DAG fer
assum0 e 3
Consi de m'n-Y P Icoe
or example mt aues n=l,
P: n d* P P:2 and9 9 .
mt
belo mes
hen t e expesio mt
P
n m t *2
3
2 3
emmon
2
us
n:5 Contaiu
m 3 Fruuons
for t e
te
Sequen ce ee But fer
Thus, t e above
m+9.
p and
and m t
aas np qes
gels
expreasions
Suc value
Sub the
ommon Sub expressi nP
p
n*P
Mot a
Hente
eappeas,
hen it
Chougec in r epeine
repeuune
on YeAult
yelultE n
expressi
C a c h Uum
sub ives ue So
ame um
Cemmon ivesfue tent each
m+ C o u u tent
Conu
expreAsien t
he 9
and q e
exxp
prre
esss
S Io
'i on
n,
m Sub
Yalues
Vaues
and ke he
Cmmon
The DAG
DAG
P p e a a n C e
poied
to h eCoun
es Sup e
the
sa
S m
ar me
e
ho donths
mt
mt?
and
a
llee Coun
9
n
Oltimalely Hhe CemnCN p
Cntueted and ie
nethoo
bunluon
eicbne
eeEtne
Gou
DAG z a l u e n
he elinminalon,
for
optimi
deaol lode
for voole from h
h he
e
from
o sb o r s
node bo s
e
a
a n
Delete
a has
has
n
no o a o d Coole
Hnat
elemdalion
T
DA G,
DA G nesulu
A Orodlen Jo
Can
Con be
be
Todentifiers
idenufiers
omespending
hese a l g e b maic ekpYesSi
ekxpresioom
agebmie
oeapevoling
a applieol ov
be ob
o Lltaa
uuua
eeol
l
al1a a n
Can be
I ransfommalion
IYamufemmallen
e4 ue
Techmig w e
lecthmig
The
Ihe
algelbmauc
Strength
ye
y eo
ollu
udcllu
ioon
n
use ata
oe Can
e a
2*
using
- isteaol
sing
using
e Coun e a
rO:5
eample a 2
s stead esie
insteao) oo
insteao
opetator
dow e streug-h tte C
Coold
e rcden
e }trdent
CLse e makes
maKes
the
opvator e applel
Stren Can
ghe Jechnigue
algebraic 2*
2 *
S
S .4
4,,
Hhe a a = C o n p u l a l + o n s
achiene using
Compilen i n
tead
ef Compilen
eliminolien, U
Uwse
e
eliminolion,
eamp
Saes
tla ekort o es a
Sus expYessien
e x p r e s s i b n
To app
Thes Sub
C o m m o n
C e m m o n
Cornrnuta t i v i o loes
bloetes
u
e e ba
b as
siic
c
a
The
Ihe
ss otialiviy ano
o
f o m i h o n s
block
block
exouple:Cousrde
t a n s
a
Covsider
a l g e b r a ie
Tox
z
be ppliea as y* z - z*y
be applieol b y hnce
Commutduwe
lau Can
Con
e p l a cee
Here veplate
Selend preasien,
and m beuomes,
* 2 .
block
optim zes
The DAG epresentaun basit blotks
e
basic blotk divetteol a tyclic gaph
A DAG o a
uodes
foLlowin abols on
elenufers, e{her
etuo
denufers,
ae labeled by cent gue
eaves
CemstaneE
Varuia ble name or an epetalor Symbol
Oakelod
abelod by
o dles
are
ntestior SeguenCe
also epuon.aly give Va
va lue s.
s
No oes e
stove te
ue Coputed
Computesd
Lolo els to
iolenkifexs for
iolenkfiers a2b+ C
b a -od
)b,d
C b+ C
do
a- d
Co
se DAG
DAG
Ceatutun
Alqendhm er
basfeblock
te
ConTaining de
k Conlaining
mpor basie
basie Llotk
Llot
fiers
t
For ideutiA
ers
identiser attached
attached
ideriti
On
a n
lu
l ut
t
a
each node
for foY Va lues.
Va ues
Computed
the OP z
Ci) X: y
Case
ti)X
OP y
Case
Case
C) X -
Methoe Creae
Creale
noole lY)
noole
tdhen
en
Step ndek
ed
vode Cz) for
Cose Cr)
Tfyis Crtalu
u n dehned,
is
Ifz
Fove he Case C), Cveale a oole (oP) ohose lelt child
u e d e (z) Jat n be Tu wde
ode (y) and ight duld
oole
Modle (op)
daleinine whethen o e ts
Fo e Casei). Such aa noole
noole
o t Create
twith oue chilol node ty). Tf
will be uodeCY)
Mode n
fox dhe Case Crii),
idenifheu Cx)
node Cx).
identifieru fr node
fom du lu t e e
Deletex
atlached iodleilfiers fer
te lut
x to Cx) to o n .
uwole tx)
Append n d
Qnd Set uoole
set
2
n step
wode
uodle n ono
d
Example:
to= a+b
(*
E totC
Example 2
statemant C
8 3: 4*
5. bs: t2 *ty
6 t pred +ts stotementla)
7pTool t
esut
o ifiK:lo goto ti ce) (TT)E ole fo 4*fo
Hoabteaoly, hente allact
due
olantif ex s to
Io
(d) (3)E cat slalement (1)
O
7
Stalemert (s)
b 1,t3
stalement (6), a a h
Slalemmnt ()
() (+E6, pmd for
ikertfi er pd
Pmd o
a , t3
To
Ch) b, prool
nal DAG
pro d o
t2
(*) (t)E, 20
A Lo
4pplialuens DA6
Sub expressLons
oletemintng the Cemm.on
mere
than onte)
Cenp ressious Comp uiteol
ued insiole
siole the
the
which names ae
. dekemining
dekemintng $he block .
oulsole
blotk ad Campileol u ld
ould
statemat
he
h e bloe k
whh statemon utsiole the block
detemining
3 have the Compuleo Value
Commin
ekeule
t
ebfective