Download as pdf or txt
Download as pdf or txt
You are on page 1of 16

Chapteo/lachme-Irtepenbnt pkinizabien

lam' 2aticn Cpthozation isa pocgam


taans/comation rechnigue, ahich toies to
mpove
hco0e Y maKIny, it wmsume less Desouoles

cPU, memoy and e.tc) and oeliven high Spee

> a i i atisn Cam e ategooíged mto2 apes

)axhire Ineporrént pnzaicn


In this 9pbimigation the compiea tokes he
mieoediate COde and toamsfoomms
a
paot o/ the
code thot cbesrot nvoke any CPU vegiskea ca

abe absotufe mèmoay kocaticn


E do
i o lo; /h's cde involves depaakd use
volue valuet item idonefie
Tem
hile (value <loo)
> ams/oomed code

Ltem=l0

veue = uaue 7tem

while
(vaue e loo)
Ln this rode e have decaoed Lem absid-
the ,
block so, vo epeaticn
Jochine- dependbnt Opbimizotien
>Feoe opfimizatien is dene oes the toageb
code is emeaaed amd he code is 2nsla
-med accoy olino to the taxget
machime aachi
-

tectuoe i.e machine oeperrbro


Tmohes CPU aegiscoos and uses ahsoute
memoaye/eaonre 2athea thon aelative eekoenr

enoiple Soue l ptiniatien


They ae also roan as rade gatimigation
techmigues
h e cde optianiaon ecrnig ues should
poessove
the eoring othe code and thei cheld
be SOme ement in he_ccde aler the
aPplicaticn other Techonigues
h e code gtimgatien techmig ues
) Commmen subeRESICN eliminabien
2 Dead cod eliminatien
3 code motion
4 cop prgogaton
5nductien vaoiable emimben & heokctian in etergt
8 Constont oldmg
) Corstont olbirg the vaue e an epoess ien
s censtont,use coYstan imteoo o expoecoien.

PI 22/7 PT 3 19
) Conmen Jub
2xp2ession Elimima in
CSE)
Commen su6
enpoess/on can be
domed
as om CXpeSSOm ahich appeaar
2epeafedy m
the pocqam and poeviously compted
hut the
vatues o The vaoiaber
n n haven
choryes
this hiseerigue we oepore the oeskutent
Commen Sub expessiem eachtme i i s
oounad

23sa -b+c e a bFC


berose the ad b =bt C
volueo
oren = = b+c g ica CSEC=6+c
0
-2 dd a-d because vaiue db
a ,a/oen
hoyed
2 Deod-ccde eliminbion, T includes the
elimmatien othog statementr which ae neve
executed 0ieecuted the aufauk bese
ctotemen is eve uNd

Ex a
a *b Y-aKb
2 -ac
2 ac

Code moten It ia ehmigue ashich move


the code oulsiok the leop, i} i osent haue
amy oleoeme exeutes mside oa ccntide
the loop
uhileCi<10) zyt2
cuhileCie10
z=y+2 ieitl
iitl
9 y npagabron. 1 we ave a py stoteme

-nt ike we can use in place ofo


in plare
wheoe eve possibe a/teo the
areuoocne of bh

statmen6
a
*b a b
2 akC

Indetiem vaoiobe eliratiom & hedycten


Inducóion vaviable elimimabion h e eliminabien
lccy centool vaaiabes.Ake ijonde.bc
Keakuctien in staergth ic te 2parement coper
CompEx
opeaahiens aith mpea e
E
j1; while Ctu
while Cie 1o)

tet+

op 4,8, 12, % -

op 4,8, 12,/6-
Znteodetion to lhth- {/ocw Aralyee
l o peoloon (odle
(ooo optimi gabio amdaode
geineation, the cempilea ned b colect m/oom
-atien about entie pocgpa ard dstoibute i?
to cach bock m the b
gaaph.
c e ane peocommg

Aocol
tanoomabiors i n a
rom as glabeal oh ou oralysi
t ce a0e peo/eomimg toomsyoomalien o r

0niroe Yeu groph lis gobo dati heos omtis


Data ler Saya tien Te dahan lhos info ran be
colected y
ut sJ= gen [s] u (Tmt]-euatien
killE)
SSatement 's.
outT->/o at the end s
gen S Iolo gorented by S.

in C n)o entas at the tegining Js


KiL nlo kiled by s
oints and laths-
d,:a-
Cuilh in a lhsic bbck B
etoeen eveay
hese is
d,-b 8
a
point adjacent ,
stotemomÍs
SB,as point
pathhe palh fom to, is a
Sequence paintr hP,3-- P d -
Such tat foo each betaeon land n-1 eilhe0-
2Ppomt immediately poecediny a statemon
Pit point imnediatel Jollooing that stakewent in
l P:- nd Seme bock
i Staobrng o a UCCesso bock
poprotes
DATAo
expaesseom a t b i r
lhaibbde expoession, m
aaibble at a pmg a emtx'
Saio

it ene i s peuns q mdilied bbre


thei use
B, , = 4 *i

B Y-x+ 2 B.P-2,3
So , ie expessien *iis avavlabe yo

y henchirg delmitien A deini bon D is 2achina


to a ot krled a
ein
telovehat thepoint

d z =X+2
da =xt
deliraben o is occchinq the bock B, auh
is rteching the pmbat block Ba, because
it iskilled a
At d, the vale
vapiable 'xis hchanged
So the dlretion kikd at d,
damobtio ta-Foar ralyais
hersic questians ohut abta-loos amlyie
thoer wht cixumtmness e iemrve
in
odata-hw amlysis reect1
) Te oeciceis the hueon baid byhe
it antive agooitan
ikeaatrve
hatis the meamrg o the sokicn b tbe eqali
he DFA pameaook (D, V, ,E) Conist .
D:Adiecion e the dhabo, eitber foocood co
backwa
V-A domain o te values
A-A mret peoatro(V) Joom a semi-attice
A fary ansoo emetins, V-> V. F
includes constant oonsleruncions oo he
EVTERY/EXIT maks as ael
Jane cK heps us 1dertily the
the oeusabe
(omppnents of the ahoithm m auo sa/ tca
oesign ocohce
ameaoaks alo hep u to calirg eoots a
DoqcommirA CO0OOS
Tomiatkice omtlabtireis aaet V ada binag
/--
meet peacdoo 1 Such that foa all r , and ihu.
apeabis
nx ( m e is idbmpotenb)
Xny =
yAx (meet is ommu tative

xnyn) = y)2(meet is assoclative)


T ruch
>A semilatbice as a o element,donoed
thot
foo allx in V, T X.

Asomilattie y ave a bottom eknt ectd


by ,such tah ab.
o0 all x n V, 1A = 1
Paotial codbaA velabionis a pootia) ooba on a
a set V, i for a l , y cmd z in V such bat

i z< the paotial oubr is eleaive)


ifreyard yex, thn zy (peotio) owbr ig
antisymoeto
y and yez, theney (pootial cdka i
tansitie
Patnl odea foa a seibßoCe e protial oadeo o
Seroilatbice (V, n) fo, all A X ardy in VV
z Sy i ond only zAy =*.

Rellexivi+fm all x, xex


paoo XAx =X SInre meeb is idempotnt
Ardisypmrameay x<y and yex bhen y
poco <y means
zAY=X &
y<X mem YAx=y
By commutativity ef A X=(A) =(AX) =x
Tersitivi xey ard yez bhon ez
pacox<y Lye2 mmans tnt
xAy =2 & YN2=y
then(xn2)=%n)nz)-(xn (ynz)-(xn)-x
lancer rancbianshe fomrily toamsea fonebions
FVV m a dbta -fbcw ameaook has
ppeatier
folbowing
F h s an identity fumetion i, Such bat l'x)-Ex
foo all i'n V.

F i r cosed undoa compesitien; Joo any 2Jmd


Cnsand g in F be parctonh oe/ined b
-

hl)-9fx) is in E.

orctenoeuk A dhta -o fameasak (DF V,A)


imenton if oa all x
omd y in V and
z <=y implies fla)e=
Distoibutive f0aearak he mecwsak s dstoihd
x ny)={o)n/(9)Jor all 2 Ay inv
an in F.
he Zerotive Mgoibhn o gnepaomecor
we Com genexalige ahooithm to make it cuk
foo a a Laety daa-lw ppoboms VC

Ag: Shaóive soluben to gerzval dito-/e foak


meul oota -ew omeuok aith be yoowing
comporeUI
oata -{low gaph aith specialhy: abeled. ENTRY
amd EXTT modes
2 A dioectien o the duh-fbw D.
3 A set e values V
4.A meet cpeaatoo A
5A set o JactionE wheae in Fs the
reansleafuretion fo0 bock 8
6A cons tnt alue
EMTERY 0arT n V, epoescntn
the bcndaoy cordi tien fo ovaaod and hok
oamreesks
Outpub: Values in V Joo TNTB) omd OUT T8J
o each
basic bock 8n the centaol ow ganph.
leaninga
adata leo
ha-loc SDlso on. he meaning
solhion is to fmda iadea)
Solutien foo the pogoan
The ideol sohutisn begins by findmg all the psibe
.
excutien paths codirg
faom the pocgonn entay b
he beginmin e 8.

The
The ioka solien he cbtaet
hem commpuer the dhla)e
value at the end d each pocsible pabh and
then appiys the
meet proata to these uokuer bo
imd theia geatest locwoo pound
ind

No enecubien o he payon cam pocoee a


mch smaleo value foo that goapint tan
IDERLLB
a a posib excuien palh Joon Minit)
staoting to B
r y amswea qoeateo thm LDEAL ave imcoaFt
fmsweas smalea tban amol equal to DEAL doe
Sae ond precise
Constamb 2opmgotin
lonstont poopogalhenis atouteplaciny expessio
ailh
ailth censtnts oo values
othe xpeSsLNs
2 % P I = 22/ =314
(2 3.11
n a code the value 3-14 ooks o e
iciently thon 22/, erose divisien isa
cempex opeaabon
(ens tant popagabiom also ellmivates uer
in ihich va/tue aroe
cpiod m one
a
C Vaoicble to antr able

L is aene by sampy asiping ehe values


X19
y 7-
2 Y (18u +2-
- Here x is assiqmedtoa censtan t and
used foo3 6mes. fo0 im poo vivg the
eeo
exerufien o e COM aue bhe vziale
aS

2 7 * (28/u t 2)-19.
aoia Kedumoarey Eliminatn
a camplezophimizathen echmig ue i
itincludes eliminabien o
'7Hobo commen sub-exppessiom elmimaben
oop inasiamt ccde matien.
i.(o Sub-epoession mabion
ACOmmen sub-epaess/©N is
hich is cused aetea dely.

t h i s emmabion ae elimimade the apabas


fexpoession ond oephced aith he okie
the expoesSI©n.

t=b+C tbt
b 2
a - btc a=t
d bt dt
the exppesien b+cis comptufed 3 bme
Heoe
o 6 emove aedumoorty are hae aphred the
ethe 2 epoecsien aith he value bhe eypersi
oop inarient code mobion In mos be
cases the exeation bime is a2akak A
caeased t h e lines coemAdre incacasad.

avoid this we emove beSome he


%
co o o he Aoop
and pare i?
umece soy

belcoe he loop

shild ie lo) y+2


while Ci<lo)
=y+2
ic it

he cxgessin t2 plared ubside the lap


he ode his
to avoid seeabed exeçabien o
Rrecen
fastea
Aoops in e pah
Loop (a be toeabed as contob
arallyst's
A lesgooph is a dhoecked gooph , it ontbins
law o (ent imfeomabien o a seb o bosc
bock
la ganph is used to depeb hoco the eego
conhol is bemg done among the bbek
loops islogoeph consis bol domincteo
depth Jhst exdeoing ack edye gaph depth
and deuc jbili by omsand etc
Domirates The mode d is said to ceniat
rode "
na
rce "
gooph i
pabh to
eveay
om mi io) ode goes
bhaough d enly
I n geneaa eveay
mbia eone noode domimm tes
all lhe Oema ming neoks tn a
bew qoaph.

Heoe rece2 ckowninabesO96.


Nakveal lop A mkiaal lop can be fine
y a back edae dsuch ba6 nekes
theis crbs moder tha& con each bo 'n 'cohi
with out going bhocaugh"d"

eae, matraal loop is


epoesenbed by back edge

6).n
a cntamt 7
m e r loop- Imea loop is a leop
olhea lecp
oe,@9, hve olhes
vo

lcopSo t is a imerlao

Poe-heaoeo- he poe-headee is a rea bock caeatr

such bhab sucecso this bock is hadeo boc


I added to facilitate lap anomben
Computabren. PDe header

heod e0
(haderJ

YCbeo bbks bock B


T is a echnigue to raveose he
he des
Cby us ig this
this taeose ave m biH
oee
- T i s exoct evese post-codlop ing
cdeoiny
post soRh a bre
1o, 9, 8,,65,4,3,2,
Depth-Jiost codesing a tbee
1,13, 4,5, 6,2,1 lo

You might also like