optcse.pas 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561
  1. {
  2. Common subexpression elimination on base blocks
  3. Copyright (c) 2005-2012 by Florian Klaempfl
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************
  16. }
  17. unit optcse;
  18. {$i fpcdefs.inc}
  19. { $define csedebug}
  20. { $define csestats}
  21. interface
  22. uses
  23. node;
  24. {
  25. the function creates non optimal code so far:
  26. - call para nodes are cse barriers because they can be reordered and thus the
  27. temp. creation could be done too late
  28. - the cse knows nothing about register pressure. In case of high register pressure, cse might
  29. have a negative impact
  30. - the list of cseinvariant node types and inline numbers is not complete yet
  31. Further, it could be done probably in a faster way though the complexity can't probably not reduced
  32. }
  33. function do_optcse(var rootnode : tnode) : tnode;
  34. implementation
  35. uses
  36. globtype,globals,
  37. cutils,cclasses,
  38. nutils,compinnr,
  39. nbas,nld,ninl,ncal,nadd,nmem,
  40. pass_1,
  41. symconst,symdef,symsym,
  42. defutil,
  43. optbase;
  44. const
  45. cseinvariant : set of tnodetype = [addn,muln,subn,divn,slashn,modn,andn,orn,xorn,notn,vecn,
  46. derefn,equaln,unequaln,ltn,gtn,lten,gten,typeconvn,subscriptn,
  47. inn,symdifn,shrn,shln,ordconstn,realconstn,unaryminusn,pointerconstn,stringconstn,setconstn,niln,
  48. setelementn,{arrayconstructorn,arrayconstructorrangen,}
  49. isn,asn,starstarn,nothingn,temprefn,loadparentfpn {,callparan},assignn,addrn];
  50. function searchsubdomain(var n:tnode; arg: pointer) : foreachnoderesult;
  51. begin
  52. if (n.nodetype in cseinvariant) or
  53. ((n.nodetype=inlinen) and
  54. (tinlinenode(n).inlinenumber in [in_length_x,in_assigned_x,in_sqr_real,in_sqrt_real,in_sin_real,in_cos_real,in_abs_long,
  55. in_abs_real,in_exp_real,in_ln_real,in_pi_real,in_popcnt_x,in_arctan_real,in_round_real,in_trunc_real,
  56. { cse on fma will still not work because it would require proper handling of call nodes
  57. with more than one parameter }
  58. in_fma_single,in_fma_double,in_fma_extended,in_fma_float128])
  59. ) or
  60. ((n.nodetype=callparan) and not(assigned(tcallparanode(n).right))) or
  61. ((n.nodetype=loadn) and
  62. not((tloadnode(n).symtableentry.typ in [staticvarsym,localvarsym,paravarsym]) and
  63. (vo_volatile in tabstractvarsym(tloadnode(n).symtableentry).varoptions))
  64. ) then
  65. result:=fen_true
  66. else
  67. begin
  68. pboolean(arg)^:=false;
  69. result:=fen_norecurse_true;
  70. end;
  71. end;
  72. type
  73. tlists = record
  74. nodelist : tfplist;
  75. locationlist : tfplist;
  76. equalto : tfplist;
  77. refs : tfplist;
  78. avail : TDFASet;
  79. end;
  80. plists = ^tlists;
  81. { collectnodes needs the address of itself to call foreachnodestatic,
  82. so we need a wrapper because @<func> inside <func doesn't work }
  83. function collectnodes(var n:tnode; arg: pointer) : foreachnoderesult;forward;
  84. function collectnodes2(var n:tnode; arg: pointer) : foreachnoderesult;
  85. begin
  86. result:=collectnodes(n,arg);
  87. end;
  88. function collectnodes(var n:tnode; arg: pointer) : foreachnoderesult;
  89. { when compiling a tree like
  90. and
  91. / \
  92. and C
  93. / \
  94. A B
  95. all expressions of B are available during evaluation of C. However considerung the whole expression,
  96. values of B and C might not be available due to short boolean evaluation.
  97. So recurseintobooleanchain detectes such chained and/or expressions and makes sub-expressions of B
  98. available during the evaluation of C
  99. firstleftend is later used to remove all sub expressions of B and C by storing the expression count
  100. in the cse table after handling A
  101. }
  102. var
  103. firstleftend : longint;
  104. procedure recurseintobooleanchain(t : tnodetype;n : tnode);
  105. begin
  106. if (tbinarynode(n).left.nodetype=t) and is_boolean(tbinarynode(n).left.resultdef) then
  107. recurseintobooleanchain(t,tbinarynode(n).left)
  108. else
  109. foreachnodestatic(pm_postprocess,tbinarynode(n).left,@collectnodes2,arg);
  110. firstleftend:=min(plists(arg)^.nodelist.count,firstleftend);
  111. foreachnodestatic(pm_postprocess,tbinarynode(n).right,@collectnodes2,arg);
  112. end;
  113. var
  114. i : longint;
  115. begin
  116. result:=fen_false;
  117. { don't add the tree below an untyped const parameter: there is
  118. no information available that this kind of tree actually needs
  119. to be addresable, this could be improved }
  120. { the nodes below a type conversion node created for an absolute
  121. reference cannot be handled separately, because the absolute reference
  122. may have special requirements (no regability, must be in memory, ...)
  123. }
  124. if (((n.nodetype=callparan) and
  125. (tcallparanode(n).left.resultdef.typ=formaldef) and
  126. (tcallparanode(n).parasym.varspez=vs_const)) or
  127. ((n.nodetype=typeconvn) and
  128. (nf_absolute in n.flags))
  129. ) then
  130. begin
  131. result:=fen_norecurse_false;
  132. exit;
  133. end;
  134. if
  135. { node possible to add? }
  136. assigned(n.resultdef) and
  137. (
  138. { regable expressions }
  139. (actualtargetnode(@n)^.flags*[nf_write,nf_modify,nf_address_taken]=[]) and
  140. ((((tstoreddef(n.resultdef).is_intregable or tstoreddef(n.resultdef).is_fpuregable or tstoreddef(n.resultdef).is_const_intregable) and
  141. { is_int/fpuregable allows arrays and records to be in registers, cse cannot handle this }
  142. (not(n.resultdef.typ in [arraydef,recorddef]))) or
  143. is_dynamic_array(n.resultdef) or
  144. ((n.resultdef.typ in [arraydef,recorddef]) and not(is_special_array(tstoreddef(n.resultdef))) and not(tstoreddef(n.resultdef).is_intregable) and not(tstoreddef(n.resultdef).is_fpuregable))
  145. ) and
  146. { same for voiddef }
  147. not(is_void(n.resultdef)) and
  148. { adding tempref and callpara nodes itself is worthless but
  149. their complexity is probably <= 1 anyways
  150. neither add setelementn nodes because the compiler sometimes depends on the fact
  151. that a certain node stays a setelementn, this does not hurt either because
  152. setelementn nodes itself generate no real code (except moving data into register) }
  153. not(n.nodetype in [temprefn,callparan,setelementn]) and
  154. { node worth to add?
  155. We consider almost every node because even loading a variables from
  156. a register instead of memory is more beneficial. This behaviour should
  157. not increase register pressure because if a variable is already
  158. in a register, the reg. allocator can merge the nodes. If a variable
  159. is loaded from memory, loading this variable and spilling another register
  160. should not add a speed penalty.
  161. }
  162. {
  163. load nodes are not considered if they load para or local symbols from the
  164. current stack frame, those are in registers anyways if possible
  165. }
  166. (not(actualtargetnode(@n)^.nodetype=loadn) or
  167. not(tloadnode(actualtargetnode(@n)^).symtableentry.typ in [paravarsym,localvarsym,staticvarsym]) or
  168. { apply cse on non-regable variables }
  169. ((tloadnode(actualtargetnode(@n)^).symtableentry.typ in [paravarsym,localvarsym,staticvarsym]) and
  170. not(tabstractvarsym(tloadnode(actualtargetnode(@n)^).symtableentry).is_regvar(false)) and
  171. not(vo_volatile in tabstractvarsym(tloadnode(actualtargetnode(@n)^).symtableentry).varoptions)) or
  172. (node_complexity(n)>1)
  173. ) and
  174. {
  175. Const nodes however are only considered if their complexity is >1
  176. This might be the case for the risc architectures if they need
  177. more than one instruction to load this particular value
  178. }
  179. (not(is_constnode(n)) or (node_complexity(n)>1)))
  180. {$if not(defined(i386)) and not(defined(i8086))}
  181. or
  182. { store reference of expression? }
  183. { loading the address of a global symbol takes typically more than
  184. one instruction on every platform except i8086/i386
  185. so consider in this case loading the address of the data
  186. }
  187. (((n.resultdef.typ in [arraydef,recorddef]) or is_object(n.resultdef)) and not(is_dynamic_array(n.resultdef)) and
  188. (n.nodetype=loadn) and
  189. (tloadnode(n).symtableentry.typ=staticvarsym)
  190. )
  191. {$endif not(defined(i386)) and not(defined(i8086))}
  192. ) then
  193. begin
  194. plists(arg)^.nodelist.Add(n);
  195. plists(arg)^.locationlist.Add(@n);
  196. plists(arg)^.refs.Add(nil);
  197. plists(arg)^.equalto.Add(pointer(-1));
  198. DFASetInclude(plists(arg)^.avail,plists(arg)^.nodelist.count-1);
  199. for i:=0 to plists(arg)^.nodelist.count-2 do
  200. begin
  201. if tnode(plists(arg)^.nodelist[i]).isequal(n) and DFASetIn(plists(arg)^.avail,i) then
  202. begin
  203. { use always the first occurence }
  204. if plists(arg)^.equalto[i]<>pointer(-1) then
  205. plists(arg)^.equalto[plists(arg)^.nodelist.count-1]:=plists(arg)^.equalto[i]
  206. else
  207. plists(arg)^.equalto[plists(arg)^.nodelist.count-1]:=pointer(ptrint(i));
  208. plists(arg)^.refs[i]:=pointer(plists(arg)^.refs[i])+1;
  209. { tree has been found, no need to search further,
  210. sub-trees have been added by the first occurence of
  211. the tree already }
  212. result:=fen_norecurse_false;
  213. break;
  214. end;
  215. end;
  216. end;
  217. { boolean and/or require a special handling: after evaluating the and/or node,
  218. the expressions of the right side might not be available due to short boolean
  219. evaluation, so after handling the right side, mark those expressions
  220. as unavailable }
  221. if (n.nodetype in [orn,andn]) and is_boolean(taddnode(n).left.resultdef) then
  222. begin
  223. firstleftend:=high(longint);
  224. recurseintobooleanchain(n.nodetype,n);
  225. for i:=firstleftend to plists(arg)^.nodelist.count-1 do
  226. DFASetExclude(plists(arg)^.avail,i);
  227. result:=fen_norecurse_false;
  228. end;
  229. {$ifdef cpuhighleveltarget}
  230. { The high level targets use the functionality from ncgnstld for
  231. nested accesses, and that one stores the complete location of the
  232. nested variable in tloadnode.left rather than only the location of
  233. the parent context containing it. This causes problems with the
  234. CSE in case the nested variable is used as an lvalue, so disable
  235. CSE in that case
  236. }
  237. if (n.nodetype=loadn) and assigned(tloadnode(n).left) then
  238. result:=fen_norecurse_false;
  239. {$endif}
  240. end;
  241. function searchcsedomain(var n: tnode; arg: pointer) : foreachnoderesult;
  242. var
  243. csedomain : boolean;
  244. lists : tlists;
  245. templist : tfplist;
  246. i : longint;
  247. def : tstoreddef;
  248. nodes : tblocknode;
  249. creates,
  250. statements : tstatementnode;
  251. deletetemp : ttempdeletenode;
  252. hp : ttempcreatenode;
  253. addrstored : boolean;
  254. hp2 : tnode;
  255. begin
  256. result:=fen_false;
  257. nodes:=nil;
  258. if n.nodetype in cseinvariant then
  259. begin
  260. csedomain:=true;
  261. foreachnodestatic(pm_postprocess,n,@searchsubdomain,@csedomain);
  262. if not(csedomain) then
  263. begin
  264. { try to transform the tree to get better cse domains, consider:
  265. + (1)
  266. / \
  267. + C
  268. / \
  269. A B
  270. if A is not cse'able but B and C are, then the compiler cannot do cse so the tree is transformed into
  271. (2) +
  272. / \
  273. A +
  274. / \
  275. B C
  276. Because A could be another tree of this kind, the whole process is done in a while loop
  277. }
  278. if (n.nodetype in [andn,orn,addn,muln]) and
  279. (n.nodetype=tbinarynode(n).left.nodetype) and
  280. { do is optimizations only for integers, reals (no currency!), vectors, sets or booleans }
  281. (is_integer(n.resultdef) or is_real(n.resultdef) or is_vector(n.resultdef) or is_set(n.resultdef) or
  282. is_boolean(n.resultdef)) and
  283. { either if fastmath is on }
  284. ((cs_opt_fastmath in current_settings.optimizerswitches) or
  285. { or for the logical operators, they cannot overflow }
  286. (n.nodetype in [andn,orn]) or
  287. { or for integers if range checking is off }
  288. ((is_integer(n.resultdef) and
  289. (n.localswitches*[cs_check_range,cs_check_overflow]=[]) and
  290. (tbinarynode(n).left.localswitches*[cs_check_range,cs_check_overflow]=[]))) or
  291. { for sets, we can do this always }
  292. (is_set(n.resultdef))
  293. ) then
  294. while (n.nodetype=tbinarynode(n).left.nodetype) and
  295. { if node (1) is fully boolean evaluated and node (2) not, we cannot do the swap as this might result in B being evaluated always,
  296. the other way round is no problem, C is still evaluated only if needed }
  297. (not(is_boolean(n.resultdef)) or not(n.nodetype in [andn,orn]) or doshortbooleval(n) or not(doshortbooleval(tbinarynode(n).left))) and
  298. { the resulttypes of the operands we'll swap must be equal,
  299. required in case of a 32x32->64 multiplication, then we
  300. cannot swap out one of the 32 bit operands for a 64 bit one
  301. }
  302. (tbinarynode(tbinarynode(n).left).left.resultdef=tbinarynode(n).left.resultdef) and
  303. (tbinarynode(n).left.resultdef=tbinarynode(n).right.resultdef) do
  304. begin
  305. csedomain:=true;
  306. foreachnodestatic(pm_postprocess,tbinarynode(n).right,@searchsubdomain,@csedomain);
  307. if csedomain then
  308. begin
  309. csedomain:=true;
  310. foreachnodestatic(pm_postprocess,tbinarynode(tbinarynode(n).left).right,@searchsubdomain,@csedomain);
  311. if csedomain then
  312. begin
  313. { move the full boolean evaluation of (2) to (1), if it was there (so it again applies to A and
  314. what follows) }
  315. if not(doshortbooleval(tbinarynode(n).left)) and
  316. doshortbooleval(n) then
  317. begin
  318. n.localswitches:=n.localswitches+(tbinarynode(n).left.localswitches*[cs_full_boolean_eval]);
  319. exclude(tbinarynode(n).left.localswitches,cs_full_boolean_eval);
  320. tbinarynode(n).left.flags:=tbinarynode(n).left.flags+(n.flags*[nf_short_bool]);
  321. exclude(n.Flags,nf_short_bool);
  322. end;
  323. hp2:=tbinarynode(tbinarynode(n).left).left;
  324. tbinarynode(tbinarynode(n).left).left:=tbinarynode(tbinarynode(n).left).right;
  325. tbinarynode(tbinarynode(n).left).right:=tbinarynode(n).right;
  326. tbinarynode(n).right:=tbinarynode(n).left;
  327. tbinarynode(n).left:=hp2;
  328. { the transformed tree could result in new possibilities to fold constants
  329. so force a firstpass on the root node }
  330. exclude(tbinarynode(n).right.flags,nf_pass1_done);
  331. do_firstpass(tbinarynode(n).right);
  332. end
  333. else
  334. break;
  335. end
  336. else
  337. break;
  338. end;
  339. end
  340. else
  341. begin
  342. statements:=nil;
  343. result:=fen_norecurse_true;
  344. {$ifdef csedebug}
  345. writeln('============ cse domain ==================');
  346. printnode(output,n);
  347. writeln('Complexity: ',node_complexity(n));
  348. {$endif csedebug}
  349. lists.nodelist:=tfplist.create;
  350. lists.locationlist:=tfplist.create;
  351. lists.equalto:=tfplist.create;
  352. lists.refs:=tfplist.create;
  353. foreachnodestatic(pm_postprocess,n,@collectnodes,@lists);
  354. templist:=tfplist.create;
  355. templist.count:=lists.nodelist.count;
  356. { check all nodes if one is used more than once }
  357. for i:=0 to lists.nodelist.count-1 do
  358. begin
  359. { current node used more than once? }
  360. if assigned(lists.refs[i]) then
  361. begin
  362. if not(assigned(statements)) then
  363. begin
  364. nodes:=internalstatements(statements);
  365. addstatement(statements,internalstatements(creates));
  366. end;
  367. def:=tstoreddef(tnode(lists.nodelist[i]).resultdef);
  368. { we cannot handle register stored records or array in CSE yet
  369. but we can store their reference }
  370. addrstored:=((def.typ in [arraydef,recorddef]) or is_object(def)) and not(is_dynamic_array(def));
  371. if addrstored then
  372. templist[i]:=ctempcreatenode.create_value(cpointerdef.getreusable(def),voidpointertype.size,tt_persistent,
  373. true,caddrnode.create_internal(tnode(lists.nodelist[i])))
  374. else
  375. templist[i]:=ctempcreatenode.create_value(def,def.size,tt_persistent,
  376. def.is_intregable or def.is_fpuregable or def.is_const_intregable,tnode(lists.nodelist[i]));
  377. { the value described by the temp. is immutable and the temp. can be always in register
  378. ttempcreatenode.create normally takes care of the register location but it does not
  379. know about immutability so it cannot take care of managed types }
  380. ttempcreatenode(templist[i]).includetempflag(ti_const);
  381. ttempcreatenode(templist[i]).includetempflag(ti_may_be_in_reg);
  382. { make debugging easier and set temp. location to the original location }
  383. tnode(templist[i]).fileinfo:=tnode(lists.nodelist[i]).fileinfo;
  384. addstatement(creates,tnode(templist[i]));
  385. { the delete node has no semantic use yet, it is just used to clean up memory }
  386. deletetemp:=ctempdeletenode.create(ttempcreatenode(templist[i]));
  387. deletetemp.includetempflag(ti_cleanup_only);
  388. addstatement(tstatementnode(arg^),deletetemp);
  389. { make debugging easier and set temp. location to the original location }
  390. creates.fileinfo:=tnode(lists.nodelist[i]).fileinfo;
  391. hp:=ttempcreatenode(templist[i]);
  392. do_firstpass(tnode(hp));
  393. templist[i]:=hp;
  394. if addrstored then
  395. pnode(lists.locationlist[i])^:=cderefnode.Create(ctemprefnode.create(ttempcreatenode(templist[i])))
  396. else
  397. pnode(lists.locationlist[i])^:=ctemprefnode.create(ttempcreatenode(templist[i]));
  398. { make debugging easier and set temp. location to the original location }
  399. pnode(lists.locationlist[i])^.fileinfo:=tnode(lists.nodelist[i]).fileinfo;
  400. do_firstpass(pnode(lists.locationlist[i])^);
  401. {$ifdef csedebug}
  402. printnode(output,statements);
  403. {$endif csedebug}
  404. end
  405. { current node reference to another node? }
  406. else if lists.equalto[i]<>pointer(-1) then
  407. begin
  408. def:=tstoreddef(tnode(lists.nodelist[i]).resultdef);
  409. { we cannot handle register stored records or array in CSE yet
  410. but we can store their reference }
  411. addrstored:=((def.typ in [arraydef,recorddef]) or is_object(def)) and not(is_dynamic_array(def));
  412. {$if defined(csedebug) or defined(csestats)}
  413. writeln;
  414. writeln('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!');
  415. writeln('Complexity: ',node_complexity(tnode(lists.nodelist[i])),' Node ',i,' equals Node ',ptrint(lists.equalto[i]));
  416. printnode(output,tnode(lists.nodelist[i]));
  417. printnode(output,tnode(lists.nodelist[ptrint(lists.equalto[i])]));
  418. writeln('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!');
  419. writeln;
  420. {$endif defined(csedebug) or defined(csestats)}
  421. templist[i]:=templist[ptrint(lists.equalto[i])];
  422. if addrstored then
  423. pnode(lists.locationlist[i])^:=cderefnode.Create(ctemprefnode.create(ttempcreatenode(templist[ptrint(lists.equalto[i])])))
  424. else
  425. pnode(lists.locationlist[i])^:=ctemprefnode.create(ttempcreatenode(templist[ptrint(lists.equalto[i])]));
  426. { make debugging easier and set temp. location to the original location }
  427. pnode(lists.locationlist[i])^.fileinfo:=tnode(lists.nodelist[i]).fileinfo;
  428. do_firstpass(pnode(lists.locationlist[i])^);
  429. end;
  430. end;
  431. { clean up unused trees }
  432. for i:=0 to lists.nodelist.count-1 do
  433. if lists.equalto[i]<>pointer(-1) then
  434. tnode(lists.nodelist[i]).free;
  435. {$ifdef csedebug}
  436. writeln('nodes: ',lists.nodelist.count);
  437. writeln('==========================================');
  438. {$endif csedebug}
  439. lists.nodelist.free;
  440. lists.locationlist.free;
  441. lists.equalto.free;
  442. lists.refs.free;
  443. templist.free;
  444. if assigned(statements) then
  445. begin
  446. { call para nodes need a special handling because
  447. they can be only children nodes of call nodes
  448. so the initialization code is inserted below the
  449. call para node
  450. }
  451. if n.nodetype=callparan then
  452. begin
  453. addstatement(statements,tcallparanode(n).left);
  454. tcallparanode(n).left:=nodes;
  455. do_firstpass(tcallparanode(n).left);
  456. end
  457. else
  458. begin
  459. addstatement(statements,n);
  460. n:=nodes;
  461. do_firstpass(n);
  462. end;
  463. {$ifdef csedebug}
  464. printnode(output,nodes);
  465. {$endif csedebug}
  466. end;
  467. end
  468. end;
  469. end;
  470. function do_optcse(var rootnode : tnode) : tnode;
  471. var
  472. deletes,
  473. statements : tstatementnode;
  474. deleteblock,
  475. rootblock : tblocknode;
  476. begin
  477. {$ifdef csedebug}
  478. writeln('====================================================================================');
  479. writeln('CSE optimization pass started');
  480. writeln('====================================================================================');
  481. printnode(rootnode);
  482. writeln('====================================================================================');
  483. writeln;
  484. {$endif csedebug}
  485. deleteblock:=internalstatements(deletes);
  486. foreachnodestatic(pm_postprocess,rootnode,@searchcsedomain,@deletes);
  487. rootblock:=internalstatements(statements);
  488. addstatement(statements,rootnode);
  489. addstatement(statements,deleteblock);
  490. rootnode:=rootblock;
  491. do_firstpass(rootnode);
  492. {$ifdef csedebug}
  493. writeln('====================================================================================');
  494. writeln('CSE optimization result');
  495. writeln('====================================================================================');
  496. printnode(rootnode);
  497. writeln('====================================================================================');
  498. writeln;
  499. {$endif csedebug}
  500. result:=nil;
  501. end;
  502. end.