Conversion of to Data Control Dependence Depemdemcel J.R. Allen Ken Kennedy Carrie Porterfield Joe Warren Department of Mathematical Sciences Rice University Houston, Texas 77251 Abatraet presented experimental ty. Program analysis methods, especially those which support automat ic vector izat ion, are based on the concept of inte~statement ~, where a dependence holds between two atatemente when one of the statements computes vslues needed by the other. Powerful program transformation systems that convert sequential programs to a form more suitable for vector or parallel machines have been developed using this concept [A1lK 82, KKLW 801. ‘ 1. The in for seems Fortran This language ,ahould level [AWSI Unfortu~ately, without the benefit effectively. from either vector with that Support Corporation. for this research was provided by IBM [A1lK Permission to make digital or hard copies of part or all of this work or personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies Permission to and copythe without fee allonorthe part thk material granted bear this notice full citation firstof page. To copyisotherwise, to provided to thatpost the on copies are not or distributed for direct republish, servers, or made to redistribute to lists, requires prior commercial advantage, ACM copyright notice and the title of the specific permission and/orthe a fee. ik date appear, and notice is given that copyin~ is by © publication 1983 ACMand 0-89791-090-7…$5.00 as @ 1983 ACM 0-89791-090-7/83/001/0177 Fartran 177 a in explicit programs in the veccor a transla- @n!w2ez 77 level translation operations and -- high d.evelop.ing 66 vector (or programs PFC). into Fortran 8x 82]. is natural assignment vector iterators. be placQ the in 100 $00.75 or language invoked This ~I hardware a be with of written operations. to vector we are lines vector operations. Rice, vector could use language Mzal.kl of may program converts assignment permission of the Association for Computing Machinery. To copy otherwise, or to republish, requires a fee and/or specific permission. write vector 8x were translated implicit At The tions to vector to operations Fortran known fix) operations. millions Fortran is b.e vector the operations. ~ utilize explicit machine replace original tor, of must vector language must to code it which fully many prior existing equivalent 1 the developed this as 81]. Fortran If to standard programmer that In ANSI vector enable programs explicit operations. next explicit spawned the array the referred such has permit and that (hereafter hardware systematito data algorithms an architectures units that vector clear contain high computer processing languages of it of vector interest will IF statements. The variables in the conexpression of an IF statement can be as inputs to the statement being conThe result is thst control dependence statement become explicit data depenexpreesed through the definitions and uses controlling logical variablea. implemented in PFC, written at Rice Universi- Vectorization developraent specification to presents a method for control dependence this fashion. The and powerful fact, One solution ie to cenvert all control dependence to data dependence by eliminating goto statements and introducing logical variables to control the execution of statements in the proIn this scheme, action statements are congram. This paper cally converting dependence in been Dependence with an have vectorizer Motivation 1.1. The dependence analyais in these systems is based on data dependence. In the presence of complex control flow, data dependence is not sufficient to tranaform programs becauae of the introduction of ~ ~ A control depen. dence exista between two statements when the execution of one statement ean prevent the execution of the other. Control dependence do not fig conveniently into dependence-based program translators. verted ditional viewed trolled. between dence of the here to Fortran a DO loop by for wmtld For to example, be the the 100 + C the vector Ideally, loop. translating DO 100 I ❑ 1, A(I) = A(I) CONTINUE translated look DO statement converted subscripts loop operaeach to a to A(I:1OO) However, the simple, in Fortran while loads 8X acid require before ‘fetch a in quite store.” a loop right of following SI That behaves side left hand as are illustrates the puted on next,B tor = 1, intent is one the its own reeults; S1 fetch from the statement of used cannot the A(l:IOO) be of as A input cycle) disappears S1 simulated by to a vec- “fetch the intermix losds its effe(ct one iteration be a in that loop same a by and as link a from called on Kuck relationship of the value graph the an if there to upon Xi upon a i., b.e ?FC called associates part iculsr S1 on itself each loop. in loop does haa also hence the run sequenin the J = A(I-1,1:10) + . . . Data a all zation. Consider of and follow- OS’i~n. by on on determines terms, does a ali.ghtly wore ~-cazx.id dependence For with the the to vectori- the whether themselves the vectorized ~ @&udeQw of the test S2 will be executed. ia considered, both dependence dependence in When SI is same does machinery not and loop is not of associated PFC with rewritten DOIOOI=l, N BR1 = A(I).G’T.O IF (BR1) A(I+l) not itself Nevertheless. outcoute control the When on indirectly. dependence a a directly depend correctly of depeudcnce .the be preclude S1 inputs. can is.. into not = B(I) any as + 10 CONTINUE sophisticated dependence.. example, S2 would not its existence unfortunately, variable. in 100P: does of That on nicely directly it S2. control because if 801. sufficient Certainly S2 any nor S1 fit not dependence S2. But the S2 depend S1 is following data for Sl Xl . . ...*Xn these S1 of statements In dimensions [Kenn considerations the s2. 51 the uses on of uimn only of relations. alcne of neitiler S1 might depends number Ken- vectorize CONTINUE of because S2 ~ Xi+l vectorized flow S2 &r.QcLQ computed time. ox often that theoxy depends demotes created. to DOIOOI=l. N IF (A(I).GT.0) GO TO 100 A(I+l) = B(I) + 10 vectorization vertex are S2 maximum important 100 rela- data However, dependence, algorithm dependence dependence describe casea each loop-carried Depemience itself. employs it 10 recursive the 100 concepts incremented that vectorized = 1, of its S1 S.2 variables ~ value xun. ~f statement have the Xn=529 all can depend term in hy between the links 78]. a se.quenco for statement the if XO=S1, I correctly I a oth- two edge these [Keun SZ at exists that on or itera- values uses each use.; S~ might S1 input such to 77]. that is concept Control ve.ctorized. which in and between WQll be and statement [Kuck the A(I,l:IO) 1.2. value another these flow definitions W ing &2f211h a be between definition the (and use so directly models fii-~ dependence be developed The directed represents the CONTINUE permitted definitions. between a array, tranaliterati.on; classical~~~ tionship ia any not produce statements not aemantica. used may the did same is statement of contraa.t, computes statement study By loop vector that distinguishing requires the with vect.orized the Correctly example stores the the be erwise, semantics. first statement by cannot Within S1 does A 51 Using + B(I:1OO) simulated of indirectly uses our and can Thufs, tion. storew in I. loop. when when can on I form =A(O:99) before statement loop the I 100 nedy with . . . of DO 100 the + location Since com- on the of only in. tially, component be to a stored loop that due iteration side + B(I) iteration statement clearly this 100 A(I) =A(I-1] CONTINUE 100 Since I ia = A(I-l,J) CONTINUK CONTINUE specific difference. DO 100 A(I,J) 90 100 intermixes hand the loop that assignment assignment the component The not vector before vector of any stored. of assignment stores. DO 100 I = 1, 10 DO 90 J = 1, 10 is semantica components fetched + C process the a scalar all is translation because is, if =A(I:IOO) ite.rati.on dependence (thereby which of a of able viewing. associating 5R1) the the to these two flow.. Control 178 to the s.tatementa data dependence becomes variables S2 a.a inputs verted the problem in the conditi.o.n. statement, ia dependence dependence. now has xith much the clear been the vari- simpler. By controlling re.lationehip. in ..terms completely of of data con- The beauty assignments of this are the scalar For example, example scheme is that straightforward condition are consider conditional to expanded a slight execution vectorize into if arrays. variation on our This by version using could the be . Fortran BR1(l:N) Many vector ditional machines have vector to select tion ia to the By generalizing be converting dence. PFC cent a in ormat 2. can idea a the into a to vectorize con- is to IF IF method data for true. The can in loops The ~ for ~ ~ some or change produce ples: (2) -in the some is the notion ~~ explicit Eion transfer in puted the goto, crested a an of module control is guard can be ments to be of be that a block Example: an call ~: more loops. take no action placeholdere but for which the be is that classification. our the IF to any the clause action words, every viewed as Zhe eliminate Fortran as all statement reason a qual,itier or or has that can be statement, branch used no to eit,h.er a the same the label phase statements as (3) of PFC the identically IF the condition. If it true, qualifier. analysis. branches can be one or types: terminates that in but .LE. at that a DO a label forward is whose the since loop DEL) GOTO 200 into branch (if the an the nesting the permitted. the or outside occurs loop not after level) target same branches are branch nesting a must label exit loop DO 100 I = 1, 10 IF (A(I).EQ.0.0) B(I) = B(I) /A(I) CONTINUE b.adwwi ~ occurring same be is at branch (if which the in GOTO 100 other be attempts program. to The nesting In level. (1) uses 179 with two branebee as a statement branch but at in the + B(I) 100) GOTO 10 this cl.assificat.ion, different within Br.aluhzduatim until to the 1=1+1 accordance sion branch before A(I) =A(I) IF (1 .LE. attached can an lexic,ally 10 place inate in which occurs). we view In etatement branches) in which Example: is aa Note which statement. conversion goto that branch action a conditional IF IF The of branch branch the in the three of state- CONTINUE . Notice is a branch the DO statement. cao action conditional a branch level. a macro- of computation. replacing . . . CONTINUE . . . CONTINUE range within statements -- by original statement purpose ti after com- staLement$ or Qa@lQkX@itQwMa evaluates conditional statements the ~~: loca- because aa to into 200 make goto, viewed IF without 100 (4) statement guard transformed than by a the 100 (2) another Note ‘iterated. ite the control Exam- which statement statement when original if with (other written computation t,o goto. ~ another the which statement branch cause conditional which is, DO 100 I = 1, 100 IF (ABS(A(I)-B(I)) action. (3) or expression under only is conjoined the cause effect. Examples: may a form: replaced For call. statements it the write, of action and the (guard) four which side -- assigned ae given atate program. each called that into statements read, action That statements of be (1) classified important assignment, ia Boolean conditions program action groups: (1) main- for c1 statements can this Conweraion be an a statement, original simple guard depen- responsible conversion Statements for is if categorized of is condition condition executed. the to IF ion. Central is statements logical transfera. PFC @ the executed computa- statements conditional of The ie IF Fundamentals Fortran via which dependence phaae transf in + 10 support applied. which program logical This statement reaches form = B(l:N) to usually this original a O hardware positions cor@rol ~ vector A(I:N) operations, mask to = A(l:N).GT. (BR1(l:N)) . statement 8x WHERR statement. wHEM . represents + 10 transformed the statement. action = B(I) of computing WarJi. ~: 100 by action loop. DOIOOI=l, N BR1 ❑ A(I).GT.O IF (BR1) A(I) CONTINUE order tained branch II? transformations the elim- of loops program. moves and converto its branchee target out are nested in the same number converts wsrd (2) each branch ~ of or branch under execution on branchea left action logic. and by Backward points following niques in sections more present these two tech- Exit ‘A(I).LT.OW is branches differ exit branches sffect ments both since the before and a branch tion of the out it from the after of loop, loop. the which branches execution of the the the following guard 100 200 Once and the jump neither is In ia. execu- statement order the to iae.ue between in example: separate of thereafter. If the doea time. DO loop is S2 will were not their terminated be present, nally pro- is exit branches within If all other every as eliminate may somehow is in branchea the remnval same with and elimination !iu3.cd expression evaluates would be the and clause. PFC data true executed converting the for t.o Fortran only is can then in each onl,y in the original to a as test of by an fied forward if logical a for a guard in vectorization we one that is employ the simplification external represen- guard erp.a 1 allows the IF us [Quin 52,. to delay con- issues until Sec- order dependence. introduce 180 ~ if not have statement compute a in a e~i the br.anc.h haa been generally. Eoolean variable is taken the original for logical modi- not expression been realization corresponding guarded an branch fla,g .th,e the sxk..~s is particular by of that be in More guarded f&g statement loop true branch of T.h,e, exit a the be a che be program. will would to while movement xeq,uir,ea. in will conjunction with the lc@p statement which an a flag a original program at rehcakicnh of only the w~ere reached using each the is branch out statement true in an of associat.e.d nal By expression in in condi- ~ might simplification to b.r.anch pr,o.gram exi., statement program. condition realization choose simple ~ we internal representations; will int of any expression which Boolean This the use of execution DO then relocation statement. and it branch computation if guard using used given external internal implicant a our inter- the the a An example. generate a guards map to ~ and by Rotationally, 7). to external that conditions from genexated. Far The exit each proc,eduxe a reason- mirrored the ~ prime to 5610 taken basis however, in of different many .Rsturning an so will naturally a provably 6. In branches exactly branch output prob- simpler. the nested the inter- the representation is conditi~~s as.swne of tion branches. ‘Jhe of si.d.eration converted then much ~ can be guards in find, logic Section being haye tation atate- from distinguish Fortran function concise. McC1 branches. target. these all correctness will compute represent quite (ace procedure them of several statement; we can the We form Quine-McCluskey complicated can concise of language suitably the eliminating becomes PFC branch its more guarda can backward if by exited. conversion words, the branches or IF loops loop exit forward of of the are since modification menta unaffected branches. forward requires completely of representation the therefore Thus. than that moat ion. a use tion we that duality in the S1 branch. into imply rep,re,een,tation GOTO 200 S2 S3 S4 statement lem a particular representation 200 con(-t). of represent logic, external will (X(I)) are guard. implemental executed ducing S1 IF opera- negation appearance for the that to our not The DO loop be The conjunction we actual guard this for nor If past certainly and issue used their In correct the the the logic and able S1 jump predicates simplification, the nally GOTO 200 taken. a P1 A P2 A ~P3 1,100 statement to on 300.W p should (V) be true statement statement. applied might was one e.g. language. DO 100 I ❑ S1 IF (X(I)) S2 CONTINUE S3 S4 he at example, for that are hold state- terminates all of formal may ‘A(I).LT.O disjunction in That branch. a DO loop affects Consider other = predicate for may (A). a p condition the guard predicates, Exit that 350. of junction branches For is Hence 3. program. execution of system that the the a system logical conditions recent tion detail. in on this predicate statement place. based of most the conditioning PFC are atoms expressing various part The in The possible state- expressions. in Guards for- branches for control these are a predicates forward expressions their procedure either branch. eliminates guard This into a backward ~ computing ments DO loops. exit denoted in the origi- defined to associated. before be with control program. exis variable we In will EXi into the program. EXi condition controlling condition is will uae will so convention represent conditions represent their used loop evaluated. the be the to exit that ~(exi) that lower and capture each realizations there entry the case of is one exit to the loop. loop branch has of within the logical flag of is that the A new branch of EXi) that by = the the the will have be been the ita moat 100 the in taken taken of by conjoining (including the loop. the S6 outer inner set Aex2A . . . Aexn. program ever so the program flag that would be will cent an is exit have been no executed, to taken, the set branch other even run arrange ia exit false, inue to flag corresponding becomes will effect to false in the Thus, the when- in DO an the by which is is the The statement in example after reloca- 100 200 .TRUE. I = 1,100 (EX1) S1 (EX1) EX1 (EXI) S2 CONTINUE IF (.NOT. S3 S4 EX1) = .NOT. loops loop sider by as the method treating a branch following a out by couputing (which those loops) branch out of outermost more the complicated of more multiple than loop. any has loop can that be implicitly that is branch left is exit set ter- branch flags can for be the every the to The loop guards the is one the the for of is called this nested DO statements loop guard other algorithm guard to for given statement recursively conjoining loop its relocation on true. itself then curxent branch initially computes guard every in for statement control. After will for guard is loops the X(I) to the IF aPPIYing GO TO 200 extended branch. The looPs under easily in have loop exit 1. the statement is a scanning algorithm an at procedure the remain corxec.tnesa This if exit are flag false. Figure proceeds tion: EX1 = DO 100 IF IF IF an flag would exit loop iterations. previous exit to to flags any an the respect exit once that jump by Y I,J) respect with the is, other Hence, identified than Here no XI I,J) applying with jump that that (indicating false. minated exit becomes by jump second Note loop. falae effected first the corresponding to original once etatement though modified and taken), the overall code GOTO 300 the exclusive; to been to loop mutually loop: this is method the exit EXI) transformation the generated each 300 eimple statements newly CONTINUE IF (.NOT. This original relocation, 200 to if the all the loop only in guards modified exl The branch .TRUE. I =1,100 (EXI) S1 (EX<) EX2 ❑ .TRUE. 100 J=1,1OO IF (EX1 .AND. EX2) S2 IF (EX1 AND. EX2) EX1 ❑ .NOT. IF (EX1 .AND. EX2) S3 IF (EXI .AND. EX2) EX2 = .NOT. IF (EXI .AND. EX2) S4 CONTINUE IF (EX1 .AND. .NOT. EX2) GOTO 50 IF (EX1) S5 an form branch GO TO 50 EX1 = DO 200 IF IF DO exit nthe at following branch are for After exit GOTO S1 of loop assignment) flag taken effect would exi been GO TO 300 since Each P condition Finally, within true, replaced have (.NOT. this program. are exited. 200 300 Upon 50 immediately the branch branch. associated the generated exit exit loop, form not IF Note a single flaga been = .NOT. execution.w simulate of GOTO S1 the would recent each exit yet loop capturea branch for all (P) EXi which out form the assignment branchea not IF is IF X(I,J) S3 IF Y(I,J) S4 CONTINUS S5 CONTINUE S6 100 the J=l,IOO S2 variables. In =1,100 DO 100 We variables Fortran I S1 variables case as 50 that = EXi. caae upper DO 200 the time in of outmost the level, program. branch on no To every exit demonstrate relocation. we must DO branches the show two things: one (1) Con- example: (2) The the algorithm removes the modified version same computation first statement 181 point S1 of as all branches. performs the follows the exit algorithm. and the exactly original. rather from trivially The body of loop of guards then expressions procedure /* /* /* relocate_branches avoiding (x); x is the DO statement for the loop loop_guard will be the conjunction all exit flags for the loop loop_guard S1:for *I exit branch that exits IF the (P) GOTO S1 loop headed by x do a new unique exit flag after the loop; replace the exit branch the assignment %Xi eXi by = .NOT. exit bound be large terminated S3:for end vectorization in branch x do no y contained A loop_guard; in x do tion of ment. Since the procedure. t’ne same tions (1) for will second about only in exit branch no point gram ia which joined program that the all to its since the exit being applied. action the Each exit $tatement of ables at determine in flag to the branch branch is replaced the jump false if ia would becomes the txue pro- lo~pa are have an condition in con- asei~nnent been words, taken the thaL effects nal effects branch that would program. A the the pute. branch have them might spe- offset this ply a exit Lbe flag on dependence Since the branch value of IF the its varimust reflect this in place, The umoved. branches execuand conversion are is the the guarda fw#ard to of is the process known all phas.e.s as (guard.) which the wi.1.l from ~ current or .be facts abo.ub as As in the the Boo,lean forward or guard variables branches not the variables LO generate whether branch statement Eo~Lean These the pre$.ently executed. to co.nditioi’i sim- reflecting d.isjoiua s.tatcxoent.. (euch rersoval is statement atateuent cuujoin> nut branch which expression it of a. a.ueI&~o moves progzam for- providing control correctly the consicle.ration the and identifica- thus expression, under the to makes Zem$Z!d. conditions for it removal. of and logical under prepaas the branch that Once represe,lt if .nQt. have place logical at in in source of guard Lhe the variables. of very is introduced occurred is conditions correctrmss have p~ssible algorithm taken in about comp.u,tation removal would save concern tran.s.forma.t.ion is a they of tbe would be taken). false. imporLant the branch idea A One a gained branches allowa between isunnecessaxy with exit controlling other the would of First. branches. depend Fundamental corresponding ‘in loop speedup targets, statement wa?JihLan.Ch is it type guard.e modi- statements. for by provide elegant backward forward the dependence guard. acts when to than an for simplest the removal that the unfortunate detection reaaona. and clearly by observa- contained bra~ch ia of Branches from pxogram, (2) though times the the is necessary S.1 is .ruodified flags is that on Second, of...eliminating two and statement be from between the is more many branches target branches. transformations original created a loop, follows difference the in assign- _ and exit an are branchea targets), contain the to branches their each code exit have insure between The brarwh generated as The The new (the level executed fied no exit even part running brancb for Forward Relocation tion a particular a branchea. results S1 converts to been computation iteration relocation distinction ward 4. Branch may long have program, - real essential will removal information 1: course no an loop loop modified P* relocate_branches; Figure its and it the the Hopefully, from thereby inefficiency. y contained (y); each non-DO statement guard(y) = guard(y) is by condition. Branch each DO statement relocate_branches This enough cial end for false DO logical variables, of in run ia the evaluating effects. out unexpectedly of aide DO loop but of purpose of will flag done. effect with realization EXi; insert the assignment WXi = .TRUE.W prior to x; = loop_guard A exi; loop_guard insert the branch ‘IF (.NOT. EXi) GOTO Sln S2: entered, some to logical branches every transformation, begin create all once being these problems eliminated, = true; each the Since *I */ of amounts in point the or.igi,- such side The values. careful original side to where ccw- bronch. at diverge from target the oixliu...ry label, flow. tile ti~e curren~ these at control where split a.t two flow flow; and rejoins coudit.ion points flow ccmtrol sequential where Thus, modified affects branch, can at the sequential (~r cc) to remove absence of must.be forward branches. they program The forward loc.atious: and (1) & trol computation 182 - ~: flow In changes, the the statement other ton- immediately following when a control branch not the predicate the guard (2) AL the Lku2 tially the and the branch is the the ccl and is statements tions, if of the should the guard A -tp), in the In ccl. In the branch, v A p). other In the A p) words, the order absence BR2, to recognize the IF of to the example DO 100 BR1 IF IF IF S1 S2 tar- path should make 60 A(I) 80B(I) =A(I) 100 CONTINUE We introduce two the these S3 ideas flag so two BR1 text are is GT.1011 called is the we BR2 br2 the in place cal at of the ~. The if and to. .true .in the first logical values that to original later = ~(bz2),. brl In inserting capture the point of change values of in inat br2, the the described in the loop conventions above. are we controlled expect. example the on a pxototype Quine-McCluskey 5.2,..McC1 56], we. that the (and the sim- thought simplifier how- had simpler) sys- implicant thought some difWhen PFC prime After correct is indeed version of this is called on is initialized and is first ing call. call, The a set of queues basic queue sions cannot is 5. Backward at statement by the a time in TRUE each the before succeedof predicate_list) Note at elim- the.existence that therefore disjoined list get reset array converted; be predicate the to procedure to assumes primitives. are to (in each then algorithm used The cco code. the conditions. algorithm original assign- logi- the branches. the only all target and must guard forward the expres- be for in that ita tar- created. Branches controlling for find S3 initially 2 outlines While. Following controlling forward-convert program program + 5 would forward e the PF.C ensures conditions A(I) =A(I) + 10 BR2 = B(I).GT.1O .NOT. BR2) B(I) = B(I) + 10 BR2) A(I) =B(I) +A(I) one realized a the By using evaluation. the we statements. removal following. .NOT. incorrect. Figure IF and IF the convert condition [Quin. branches statements, assignments accidentally ments .OR. this used was only variables of aspect the condition. = A(I).GT.1O = B(I).GT.1O IF two variables the the ❑ A(I) what ran that produced ments: BR1 BR2 first ever. to loop. true by the from tem be the accomplished and in Fortran capture and brl ~ to evaluates = ~(brl) this ferent simplif,iex conditions defined We use ,BR2 to that Note plifier branch brl statement. BR1 and (BRI B(I) CONTINUS 100 +4(1) variables always important would I = 1, 100 = A(I).GT.10 (.NoT. BR1) (.NOT. BR1) (.NOT. BR1 .AND. IF S4 clearer. GO TO 60 =B(I) - 5 Boolean variables NA(I). PFC x is A(I) =A(I) + 10 IF (B(I).GT.1O) GO TO 80 B(I) = B(l) + 10 S2 S3 S4 if into recogis simplification, in able logical surely S4 an x S1 Such is BRl be simplify should controlling With above must = reaches reach condition procedure statement flow and it long like procedure simplification loop of variables example, conversion. example proliferation logical conversion the Thus, of the identities conversion CC2 simplifies IF For that true. target execution DO 100 I = 1, 100 IF (A(I).GT.10) branch prevent involving taken. capture brlV(wbr1Awbr2) brlV(mbrlAbr2)V(-?br1A*br2) to and nize to that target will which prior (so control flow of the the which if control regardless An lbrl -tbrlA-tbr2 expressions. assump- on flow on (ccl via statement guard can sequen- previous the control guard A -!p) the the CC2 V (ccl flow or condition p. will either statement on CC2. changes (CCI branch previous is be control the Under target other controlling .51 S2 S3 S4 current branch following Similarly, target itself. get branch if statement only expressions from branch is forward ~: the ccl the Thus , controlling for executed A ap. reach the is reaches taken. at ccl branch flow is condition be forward forward that by branch the the s,tate- quite type control In following branch branches of fact. branch creates cannot PWIWS; thus eliminated. 183 from struct can it dependence backward e.liminat.ed conditions. removal handily, a an be backward eliminate cannot - backward branches cannot program, because implicit simulated branches forward remove loop. a directly backward looping guarded cannot last branches. be A with the be constate- directly 100 is taken. One procedure forward_convert returns (x, avoids cc-o) condition; to /* x /* /* cco ccl /* 1* /* predicate_list(x) is a queue of all predicate that must be disjoined at x becauae of branchea to x. ccl the stat~~ent is under ~on~id~ration ia the condition prior will be the condition to x. guarding x */ their a) */ */ *I implicitly bits S1 ); S1 is in These /* GOT’O y (forward to same level) begin add_ko_queue (predicate_list(y). set paas a of ); removal in DOL handled be because of branch the statements would by code */ Branch of the more problems Forward backward a~gorithm than branches in One branch if are two Forward ~ executed branch set the following: GO TO 200 becauae when X is it aa taken. In other the using first backward the words, realization jump idea to the a BB) will has been previous and example Guard -tbrl v true ?br ~ true (brl A bbl) mbrl v (bz~ = .FALSE. A bbl) true THEN point a branch is back that BB1 is set to true occurs. to ways can our that be two the reached EdlthKough: alternatives. target from y the to -tX. prevent the in This S1 backward Figure guard from the 2 (7-) is of atart branch by there a of backward the pro- BackMad bbj) 184 path the y. is fall through The condition taken ccunplete.ly is on Curs.nLmditizn from under exit from predecessor. krau.11: control iterative branch to can before this implicitly being control statement encoded illustrated S1 would true been the whenever = X which for true by on gram. GO TO 100 removal false flag to y. region bIi and The condition branch can by enter a branch backward under a passes. established ia (with firat and subsequent and this BR1 . . . BB1 S1 . . . S2 the guard be the region region that Corresponding 2. ... would fact noteworthy only (1) (Y) guard can bb approach: guard can- Figure ““” S1 . . . S2 IF to which flag to BBI = .TRUE. GOTO 100 ENDIF branch 200 the backward a generalized iterative used has . . . IF (Y) Removal. hawever. the like (X) that Statement create presence through produce: 200 the we x Forward IF 100 is the denote time used implicitly conditions k@2.k forward_convert; loops. ao A guard pass any ia variable bx.ax&h first suggest through 100 branches severe, carefully. false. executed an guard pasa the X is conditions Boolean (ccl) implicit an taken. set These */ CC1 ia through esac; Backward inhiinto taken. /* All other type begin guard x by ccl end just alternatives: on if Applying 2. two ahtaya different end Figure quite more alternativea one backward end under approach branches seems executed only branch /* IF(P) GOTO y (forward to same level) */ begin create a new branch flag bri with realization BRi; replace x with ‘IF (~(ccl)) BRi = P;”; add_to_queue (predicate_list(y), CC1 A bri); ccl + ccl A -tbrl end return ia code ~ this problem reflect ia code (2) ccl +- false; delete statement the region. the S1 must that branches ~ forward limitation consider an course, any conversion ) do ( predicate–list(x) statement_type(x) of IF backward leaving as Of iterative This end case (known removal (1) P ‘- get-from-queue ccl + ccl v p to of branchea, untouched. for ( predicate_list(x) these control must not_empty approach complications isolate */ */ + Cco; while begin possible the which the with (flag this can happen is true when the the bri condition from and backward Hence, the branch is the guard at there ia region. of more the the the each backward forward branch condition was the target ‘l’he alao be one jump procedmre returns true. the into should backward the be the at modified. the x cco ccl the bbj. end c*ee must following (X) GO TO 200 S1 GO TO 300 S2 IF (Y) GO TO 100 100 200 300 The 53 correct S2 ia to 200 been ing guard executed wae S2, the ward branch regions the term into the target pasa to after aignifiea complete branch ( predicate_list(x) x */ */ ) do ( predicate_liat (x) ); in to same (x. y, same level) */ bri BRi = PW; A bri); ) *I level ccl); x GOTOY bb. wit~ insert let TPk replace ~Pk ‘IF ‘IF ‘IF each in may first example (~ to same level)*/ be branch back flag aeaociated this branch (realization: BBj ); %Bj-= .FALSE-.N before y; be a new eemporary variable; x with the atatementa = (CC1)W (TP ! ) TPk = Pw (TPk) BBj ❑ ..TRUE.n (TPk) GO TO yn end; becomes f*--kl4 other begZn guard (x) ad esac; return (ccl) remove branches; =x the :urrent with. the result rors the after fact Figure. condition.of target major Figure 2 the 51 */ Y) THEN end Figure 3: statements */ +guard (x) Conplete A ccl branch removal Also. note rated at that defeat the the of which alwaya be executed. these 4), implicitly block purpose equivalent .of IF statements branch, IF whether ,conv.er.sion. assignment not is branch into the .c.u.rrent conditi~n. simplifies target citly gene- of generated. entry 185 the of last all the current forward the that afiter condition backwards another back the flag the the impli- simplification condition last .a that after into This the of of are ia enters branch branch the cases control never the in E!PC has there prea,ence flag region. fact Statements to the the the back Second, iterative reflects a Without out of special. unless under branch used no b.ranchea region branch. in ptocedur.e First. backward .Che svould Ina.tead, for branch. forward these needed in regions. are. ,ai.n.c.o removal advantages. backward al.gor.ithm iterative branch several ,remo.val encapsulated on .The ,mir - observations. the check. backward branch. dis- A bx.1.. true to (Figure jump .into is v bb.1 is incorp.or.ate.s the A brl -tbrl genezal modification is pr.oceas._branc.h branches S3 should contains which only -tbbl condition .simplif.ication that 3 algorithm sequence ~F--(p) and the to x S3 The The on previous (.NOT.BR1 .C)R. BBI.AND.BRI) GO TO 300 has been eliminated (.NOT. BBl .AND. BRI) S2 (.NOT. BB1 .AND. BR1 .AND. BB1 = .TRUE. GO TO 100 ENOIF 300 S3, removal +* begin let coutr.ol only The condi- flags */ prior after end a for- for back that statement regions. not flag IF /* IF IF 200 joined flag condition the consideration. condition condition ccl + falee; delete statement iterative branch back target for the branch these preced- implicitly of of BR 1 At the baa target under current current /* GOTO y (forward beg in proceaa~bzanch since branch the statement the the statement_type(x) branch branch condition branch of 100 in negationa the iteration be multiple of The A -tbbI, forward the target conjunction negation bzl the remove must the be if backwards to mbbl the only the order general, .is region. and In In S2 must and taken taken, tion. for if the is is CCO) /* IF (P) GOTO y (forward to begin create a new logical guard with realization BRi; ‘IF (y(ccl)) replace x with process_branch (x. y, ccl CC1 + CC1 A -tbri end example. IF ia (x, P ‘get-from-queue ccl + ccl v p target Conaider /* ccl + Cco; while not_empty begin iterative with remove_branches condition; /* /* disjunction conjoined generated slightly of was branch A bbj) condition condition to branch the term branch is set J incorporates of than second bb. it target CCY V (bri If Since occurs, that reached the A bbj. branch for p.o.ssible branch execution external should be independent wards of any branch. ability of cal specific Most the iteration algorithm combination of important, of the to handle backwards is any branches there back- however. the the exists literals pathologi- with Hence minimal three no shorter in @ that the conjunction aleo of implies Quine-McCluskey a subset of ~. procedure contains phases: effort. (1) 6. Boolean In developing conversion. of have issues two representations. for one basic to we need some mechanism put program will be for we the need to by and find the that are cants to (3) Phase the number out- simple simplification function external representations. are maintained forming val the -- be possi- at a McCluskey McC1 branch applying prime the the branch remo- actual implicant merging the simplifier ing discussion. and negations Ln of ~ a a Any (~ Boolean of if no of is variable of is an ensu- known tial since give rise the as in This a Y be fundamental variable are each a aet eet of. of. all i.t formula in t. is.a Y occurs n,var.i.ab.les in in..Y, minterm can mi,n@nn it, are denote Y PF.C, alternation, fo.rmula, of miuterms; rep.r.esentat.ion. as.., . . ~..~ McCluakey there or reducing t.hers then finding for the is-~ aet t.o of we .written, refer the ~.. .simpli.fies to .The .Boolean canonical disjunc.tive.. a.miuimal set rointerms, of ,aa ~ . pzo.cedur.e and cam,be, A a as Z ita active of At at the which such one exponen- m variables time that removal 1 can only Quine- is take branch created. advantage are two the of guard to c.o.ndit.ions in the the.set the us of maintaining over allowa a forward created and modified of dur- ways: it b.y (2) by form formula 1 branch two a. new conjoining current condition this result the flag in. the . The, one,e current and its the. branch. be its with by the con- negation negation the to col- comprise next etatement unnegated attached condition to Inter- condition the for is formed negation effected current with ones the flag are at and condition the bxanch it can new mintern. new, conditions flag to the branch. the At. @ and 186 a target must be dled by same set union of tions. @ a is How - PFC minterms representation while. Qr Qu.ine- normal if it nine. is in phase lection.. this, formulas fundamental the requirements. formulas internally a set the .of..-,~ formula ia methods potentially in comprise Boolean m so also by every negation, Every good However, or slower avoid joining .s.ince a variable and eight we nally, A each If a 82]. technique short best Phase 2 can to nl.5~ storage is the the storage, than slightly 1 in since [AIKW procedure branch by if .rmce,, either that 2m minterma. ing (1) Y. 2? minterms,. I 0(3m) m larger a few to observation called over over exactly there contain We formulaa such is fundamental are variables. normal S CE minterms in original the the. set proportional used Phase from Let = ~. necessary, of smaller the &rlU.. nf(Y) W acceptable. Simplification guards as formulaa alternation then complexity time exist 561. flags to appears fundamental and it the variables literala implialterna- the 52, b.e referred ).~iimaula which for formula. will alternation “ formulaa notation variable.e Quaul.a twice. of A conjunction . canonical prime is but is requires much In a bit E, strictly S number for McCluskey with of not variables there [McC1 Quine- [Quin the method iea We begin to all V~ implicants. in is of 6.2. Prelimin*r If shortest select McCluskey~s two 56]c 6.1. E of combinatorial is n have simplification of of to ever, of version a the prime impractical guards per- and set members implemented the to quickly flag The label. by into for operations a new the formula. of is of heurietic representations suitable fundamental performed built all simplification other as Internally, a form creating conditions is in is internal maps of 3 number which 1 guards representations as the Selection where ~ formula VP e! $. ble. The the of for tion correct, In readable. external which operator of Construction conver- be insure (2) exter- IF that IF factor one will to clean conditions referred and program but worda, We have insures output for to constructed method the basis attempted internal conditions The s ion. attached conceptual purposely representation. the to form. the we out nal, Reduction Simplification collection some disjoined.. extending of all This the variablesminterms of conditions disjunction minterms then in the to is. be simply various over. taking hanthe the collec- Conditions in parts. The list of a set the minterms simple used. in the the branches second condition. should clarify At statement is disjoined 200, expression the current brl br2 A condition, br3 A giving: (IbrlAmbr2Awbr3)V(wbrlAbr2Abr3)V (mbrlAbr2A=br3)V(-tbrlAmbr2Abr3) these The the the with part of actual (-sbr1A-rbr2A=br3)v(*brlAbr2Abr3)v(-tbrlAbr2A-br3) a condition, disjunction following IF (X) . . . IF (Y) . . . IF (Z) two is forward The The by m) the the encountered. example Consider ~ that minterma. repreaenta A represented ~ present order were of (the flags in represent is actually part branch maintained they PFC are first first and abr2. method The *brl code: A =brl. GOTO 300 minterma and br2. These Finally, at simplified GOTO 100 laat second out. simplify third minterms 300, the -tbrl A simplify combine statement resetting to minterms to the produce flag current to -tbrl is condition to true. GOTO 200 This example Once a leada to several new obsena- tions. 100 ““” CONTINUE 200 ““” CONTINUE . . . CONTINUE (1) 300 each of condition is produce the the dition. a to be A br2. which expand the (-tbrl not in Qf A brz joined The be transformation Thus the by current current in it A br2 no than after (2) The as the A br3) is order reverse. of the is the /* x y is the target br is the condition before condition). 100 is The proof but not itera~ive let bb. be the con t rolling xj be.the x jumps branch the target back of *I */ */ br do flag as Figure 4. Branch be the the branch previous the sim- exactly example since clearly, current br3 condition removed. be, same insure is the. the woret the time Note .,that see condition they are ao. method in simplify brn may the. is the . ..Abrn be has removed checked. c.ondi.ti.on. ordering the with teeting p.redeceasor. to regardless to. element carefully added simplification .v.e.ry of. minterms s.imp,l.ification ;..othe,rwis,e,,. By struco,u.t this required each its the.t.ar- case,, involvea if If and growth chose.. branch local,- siu@ify. Since . ..Anbrm. mint,erm, F.o.r be How- last containing flags merely t.o indicate. code we. can r.epreaenta- o.nly,when.the of in optimize that we simplification for,guards. ..branchea. entry. terms. aa space, reader shortest dia.cussions branch mipterms the of on the occurs code. simplest 187 than representation texms report represen,tatian, .of. straightforward interested, representation p.revious structured cient. technical exp.o.nenti.al to is interest The. section all the the, earlier after this. statements growth shortly order. brAbbj); our. a partner ?roeessiag may S2]. branches. the.. Forward a tured, o.f process_branch; The here. around.a of frmu. end be larger this can region; of. A atmt_guard); of which point In minterm ever, gets region (predicate_liat(y), can it [AIKW tic!n, set. add_to_queue was is in from these to The branch the backward branch; add_to_queue (predicate_list(xj), stmt~uard + stmt_guard A mbbj e md order removed obvious. PFC br); into branch execution flags condition introduced. br2 omit .jumpa + true; implicitly that begin let the the the merged the branch on have the branch the this be exponentially /* /* stmt~tta-rd for each y, are must in (x, which of referred process_branch in demonstrates dis- implies since flag on the con- statements. out will procedure flag V simplifica- statement a not effect of the patha the or no plified flags of with have out reenters execution Whether will simplified never disappearance possible subsequent we reversing target together. taken is condition, expression the condition 100 rewriting this to includes is it associated as The statement (mbr~ (other made branchea. conditiou, performed =br3 condition minterms: When A all branch flags -sbr2 target condition two the can at the current branch, A current A -tbr3).. with tion the the all disjoined target disjunction the nbrl after Since ia passed, with minterm condition expression br3, are conjoined single current nbrl branches flag condition, that As branch current condition, acceptably for is the .we in mincan effi- Afterwards the generated using McCluskey procedure. only when the This scheme wards branch to expanding the be by current implicitly and 3 the the region is ia to erated SO, encountered. Basic pasaes analyzes ward in the over val. These above, although order to is the exit are promote only guards axe as. .al.l converted other program to have been .to the WHILE is same backward 100pa. removed the At from the abstract order blocks branches and converts all branches point, over of IF the the Figure prior loops and basic 5 to briefly IF outlines can In torized IF analyzes block the. the structure normalizes These transformations tion, constant to uncover its [Kenn 811. DO loop propagates loops are expression & inside increase the re.zulting to .code, Another is. important recurrence of the to the easier the rather this strictly to tha~ using on problem are arrays IF of scalar v.ariabl.es. by breaking. three. in IF converting some dis.t.inct conversion, First. directly. conversion of use. vectori,zation. ing flags logical allo.wa ‘the the scalar There a code cause thereby scalar by of parallel can inhibit. variables. using approach 100PS replace ,dependences. part earlier, DO will array performed is during described thereby advantages 188 greatly Second.,. which inaide expans.icm equivalent PFC First, or transformations phase As flags Scalar of transforma- reasons. transformation breaking generation, Structure This actual in.appearance ~, dependence,. 5: the flags the inhibit closer making ~ scalar Figure by vectorization. much block understand. Pl?C tire-w of is. within basic replace two either true substitu- the flag. for cost implicit the forward by will the DO loops code original. IF Conversion .to eliminawui.abk of a .1OOP advantageous scalars code expressions within assigned is global variable set basic unvec- program. the replacing propagation constant of applies functions limi.t.s sucafter i.dudsm to basic to constructs. dead induction This aoalysis). the of to with the use exists IF and fact execution use PFC certain (within tion block addition variables, the the it the include In —— -----. HiE!!34t!2E_l-] induction that into variables accurate of incorporation propagation. . induction tion as conversion. of less to in horren- conversion transformations DO program structure the become used be use able IF addition, statements IF far program facilitate After PFC the conversion. program. conversion, we are optimize has change before the were would making not the Specifi- blocks cases. does Note in increases statement by IF global statement analysis many program, opt, imizatiou PF.G.. in to the program. these However, of easy conversion. a every the constructed blocks in If and to greatly and conversion cessfully form pass slow, IF performed the IF guard loop important vital every itself. the level allowing not is following blocks possible. that is it In gen- loops. guarding optimization, than condi- baaic to global of conversion every block dously final this a in intermediate of cally, described Afterwards, A number remo- simpler previously expressions.. unlocks them backbranch slightly and removal. pass branch IF out but explicitly program, Next as using branch first differ efficiency three marking by basically described during code, algorithms Simplification representation The followed passes in branchea. performed, the performed program. in and is t ions, the branches branches relocation PFC thereby analysis phase b~ nesting one are of the noted, directly, from one. identification jumps block conversion that separate of optimization conversion easy run “of variables Additionally, is to increments induction allow statement the loops by loop determination list all bound new which every branch Implementation IF upper controlled. back- into modifies some altered. flag branch normalization doing handle branch - required backward first be Quine are to conditions iterative the condition expanded adding when may of phases current also flaga and condition 2 These actual can flag ?. simplified phases to focus control dependence -- tedious details Second, this not created the approach. greatly it unless not are a scalar arrays for is that two the of not they recurrences Scalar however, in in PFC; by any tested expansion U. Banerjee, ~ata dependence nary programs,n Report 76-837. vec- ment of Illinois Illinois, conversion [BohJ 661 dependence may dependent IF conversion Vectorization of Qtherwise of here, with not IF are be unwieldy, the run January short we code IF to D. Harel, ‘On folk theorems.w 23, 5, July 1980, 379-389. [Kenn 801 K. Kennedy. ‘Automatic translation Fortran programs to vector form.” 476-029-4, Technical Report University, October 1980. [Kuck 771 D.J. Kuck, ‘A machine organization ~ 29-59. [KKLP 811 D.J.-Kuck. R.H. Padua, and transformation c.onverwion to trol depend.ences sion is useful languages, More code has to in can structured known as 66, well as briefly explored in far beyond IF as and goto deumnstrates system that This 801, practically a 801 the lM2s2. [AIKW 821 821 R.H. Kuhn, ~he structure AGM d Vs.. for B. of January pipelined Leasure. and an advanced processors.” *CalWt&LSWiS4~ Sd&alX% and IEEE , Chicago, GQUL. * flow October any intellectually [McC1 practical 56] branching though to a [Quin 52] well 1980. E<J. McCluskey. Boolean L. 35, functions,n 5, November W.V. Quine, ~he truth functions,” 8, October 1952, pleas- useful. J.R. Allen and K. Kennedy, ~FC: a program to convert Fortran to parallel form,w Report MASC TR 82-6, Department of Mathematical Sciences~ Rice University, Houston, Texas, March. 1982. J.R. Allen, nSimplifieatien PFG,n Dept. University, Kuhn, B. Leasure, D.A. N. Wolfe. ‘Compiler of dependence graphs,” conver- K. Kennedy~ and J. Wa*ren, of. Boolean fe-ulas in Mathematical Sciences, Rice Houston, Texas, November 189 Minimization U 1956, problem Sy&tem 1417-1444. of Am. M&h. 521-531. of M. simplifying Mn.thly 599 [Towl 76] t~Gentrol and data depenR.A.. Towk!, program transformations,” dence for Ph-.D . Report 76--788s Dissezt. ation. Dept. of Computer Science, University Vrbana-Champa ign. of Illinois at Urbana, Illinois, March 1976. [Wolf 78] M.J. Wolfe, ~eehniques the inherent parallelism Report 78-929, Dept. of University of ence, Urbana, Uzbana-Champaign, July 1978. References [A1lK D.J. Kuck, M. Wolfe, vectorizer con- data converted result, ia of Rice Rice elimination. in successfully AGM parallel of programming.w March 1977, survey and 9, 1, ReU2r.& Qf&.hfili@Lh Qll IkiU&@l Williamsburg, Fs Gfunu unvec- converting dependence. structuring, Hare Gi2nL. f&WI [KKLW application construct. [BohJ the become guards By data such be. since constructs. transformation construct only implications it conversion rapidly vectoxization. generally, program IF described examples. converting block IF 1981. 801 implemenas ‘Implementation Scientific Pro- [Hare must simplification to have of permits PFC present result. tends Second, applications ing on a 1966. false. extremely that First. As May enough more it complete exceptions. possibilities torized The is condition an because code untouched. c.omp.leted. only current be 5, C. Gibbons, and K. Kennedy. ‘SimplifiRice Technical cation of functions,w 476-029-10, Rice University, Report false analysis permitting to PFC of conversion two yet ip 9, 811 to sophisticated proved sections leave tation can has hnnuAGM [GibK particular. dependence transformation Tlow Jacopini, machines, and formation two and G. Turing with only Burroughs Corporations, of FORTMN,W Burroughs cessor brochure, 1977. Conclusions valuable Bohm diagrama, languages 77] in ization. s. ordiDepart- [Burr when rise thereby in Computer Science, University of at Urbana-Champaign. Urbana, November 1976. c. rules,n Institute, for Fortran document), determine the.dependence them. 76] dependence In is these [Bane vectorization gives by American National Standarda Inc., Wroposals approved 8X,W x3J3/s6.80 (preliminary November 30, 1981. however, IF PFC are flags ignores required the independent. that and some created 811 by can Unfortunately. exit when recognize vector unless in are of gained permitting [ANSI are scalar expansion, references expansion phase. PFC. exact array actuality storage dependence phase testing is 1982. tbe arrays. arrays every of Scalar Third, analysis that necessarily expand with to vectorization amount all. tested concerned scalars expanding the at results. is some without torization be guarantees Strictly increase will not converting approach a program. to need of for improving in programs.n Computer SciIllinois et Illinois.