2
0

aoptcpu.pas 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  1. {
  2. Copyright (c) 1998-2002 by Jonas Maebe, member of the Free Pascal
  3. Development Team
  4. This unit implements the PowerPC optimizer object
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. Unit aoptcpu;
  19. Interface
  20. {$i fpcdefs.inc}
  21. uses cpubase, aoptobj, aoptcpub, aopt, aasmtai,aasmdata, aasmcpu;
  22. Type
  23. TCpuAsmOptimizer = class(TAsmOptimizer)
  24. { uses the same constructor as TAopObj }
  25. function PeepHoleOptPass1Cpu(var p: tai): boolean; override;
  26. function PostPeepHoleOptsCpu(var p: tai): boolean; override;
  27. private
  28. function cmpi_mfcr_opt(p, next1, next2: taicpu): boolean;
  29. End;
  30. Implementation
  31. uses
  32. cutils, cgbase;
  33. const
  34. calculation_target_op0: array[tasmop] of tasmop = (a_none,
  35. a_add, a_add_, a_addo, a_addo_, a_addc, a_addc_, a_addco, a_addco_,
  36. a_adde, a_adde_, a_addeo, a_addeo_, a_addi, a_addic, a_addic_, a_addis,
  37. a_addme, a_addme_, a_addmeo, a_addmeo_, a_addze, a_addze_, a_addzeo,
  38. a_addzeo_, a_and, a_and_, a_andc, a_andc_, a_andi_, a_andis_, a_none,
  39. a_none, a_none, a_none, a_none, a_none, a_none, a_none, a_none, a_none, a_none,
  40. a_none, a_none, a_none, a_none, a_none, a_cntlzw, a_cntlzw_, a_none,
  41. a_none, a_none, a_none, a_none, a_none, a_none, a_none, a_none,
  42. a_none, a_none, a_none, a_none, a_none, a_none, a_divw, a_divw_, a_divwo, a_divwo_,
  43. a_divwu, a_divwu_, a_divwuo, a_divwuo_, a_none, a_none, a_none, a_eqv,
  44. a_eqv_, a_extsb, a_extsb_, a_extsh, a_extsh_, a_fabs, a_fabs_, a_fadd,
  45. a_fadd_, a_fadds, a_fadds_, a_none, a_none, a_none, a_none, a_none,
  46. a_none, a_fdiv, a_fdiv_, a_fdivs, a_fdivs_, a_fmadd, a_fmadd_, a_fmadds,
  47. a_fmadds_, a_none, a_fmsub, a_fmsub_, a_fmsubs, a_fmsubs_, a_fmul, a_fmul_,
  48. a_fmuls, a_fmuls_, a_fnabs, a_fnabs_, a_fneg, a_fneg_, a_fnmadd,
  49. a_fnmadd_, a_fnmadds, a_fnmadds_, a_fnmsub, a_fnmsub_, a_fnmsubs,
  50. a_fnmsubs_, a_fres, a_fres_, a_frsp, a_frsp_, a_frsqrte, a_frsqrte_,
  51. a_none, a_none, a_fsqrt, a_fsqrt_, a_fsqrts, a_fsqrts_, a_fsub, a_fsub_,
  52. a_fsubs, a_fsubs_, a_none, a_none, a_none, a_none, a_none, a_none,
  53. a_none, a_none, a_none, a_none, a_none, a_none, a_none, a_none, a_none,
  54. a_none, a_none, a_none, a_none, a_none, a_none, a_none, a_none, a_none,
  55. a_none, a_none, a_none, a_none, a_none, a_none, a_none, a_none, a_none,
  56. a_none, a_none, a_none, a_none, a_none, a_none, a_none, a_none,
  57. a_none, a_none, a_none, a_none, a_none, a_none, a_none,
  58. a_none, a_none, a_none, a_none, a_none, a_none, a_mulhw,
  59. a_mulhw_, a_mulhwu, a_mulhwu_, a_mulli, a_mullw, a_mullw_, a_mullwo,
  60. a_mullwo_, a_nand, a_nand_, a_neg, a_neg_, a_nego, a_nego_, a_nor, a_nor_,
  61. a_or, a_or_, a_orc, a_orc_, a_ori, a_oris, a_rfi, a_rlwimi, a_rlwimi_,
  62. a_rlwinm, a_rlwinm_, a_rlwnm, a_rlwnm_, a_none, a_slw, a_slw_, a_sraw, a_sraw_,
  63. a_srawi, a_srawi_,a_srw, a_srw_, a_stb, a_none, a_none, a_none, a_none,
  64. a_none, a_none, a_none, a_none, a_none, a_none, a_none, a_none,
  65. a_none, a_none, a_none, a_none, a_none, a_none, a_none, a_none, a_none,
  66. a_none, a_none, a_none, a_none, a_none, a_subf, a_subf_, a_subfo,
  67. a_subfo_, a_subfc, a_subfc_, a_subfco, a_subfco_, a_subfe, a_subfe_,
  68. a_subfeo, a_subfeo_, a_subfic, a_subfme, a_subfme_, a_subfmeo, a_subfmeo_,
  69. a_subfze, a_subfze_, a_subfzeo, a_subfzeo_, a_none, a_none, a_none,
  70. a_none, a_none, a_none, a_xor, a_xor_, a_xori, a_xoris,
  71. { simplified mnemonics }
  72. a_subi, a_subis, a_subic, a_subic_, a_sub, a_sub_, a_subo, a_subo_,
  73. a_subc, a_subc_, a_subco, a_subco_, a_none, a_none, a_none, a_none,
  74. a_extlwi, a_extlwi_, a_extrwi, a_extrwi_, a_inslwi, a_inslwi_, a_insrwi,
  75. a_insrwi_, a_rotlwi, a_rotlwi_, a_rotlw, a_rotlw_, a_slwi, a_slwi_,
  76. a_srwi, a_srwi_, a_clrlwi, a_clrlwi_, a_clrrwi, a_clrrwi_, a_clrslwi,
  77. a_clrslwi_, a_none, a_none, a_none, a_none, a_none, a_none, a_none,
  78. a_none, a_none {move to special prupose reg}, a_none {move from special purpose reg},
  79. a_none, a_none, a_none, a_none, a_none, a_none, a_not, a_not_, a_none, a_none, a_none,
  80. a_none, a_none, a_none);
  81. function TCpuAsmOptimizer.cmpi_mfcr_opt(p, next1, next2: taicpu): boolean;
  82. var
  83. next3: tai;
  84. inverse: boolean;
  85. begin
  86. result := true;
  87. inverse :=
  88. getnextinstruction(next2,next3) and
  89. (next3.typ = ait_instruction) and
  90. (taicpu(next3).opcode = A_XORI) and
  91. (taicpu(next3).oper[0]^.reg = taicpu(next3).oper[1]^.reg) and
  92. (taicpu(next3).oper[0]^.reg = taicpu(next2).oper[0]^.reg);
  93. case taicpu(next2).oper[2]^.val of
  94. 1:
  95. begin
  96. // less than zero or greater/equal than zero (the xori remains in
  97. // in the latter case). Doesn't make sense for unsigned comparisons.
  98. if (p.opcode = A_CMPWI) then
  99. begin
  100. p.opcode := A_SRWI;
  101. p.ops := 3;
  102. p.loadreg(1,p.oper[0]^.reg);
  103. p.loadreg(0,next1.oper[0]^.reg);
  104. p.loadconst(2,31);
  105. asml.remove(next1);
  106. next1.free;
  107. asml.remove(next2);
  108. next2.free;
  109. end
  110. else
  111. result := false;
  112. end;
  113. {
  114. needs two registers to work with
  115. 2:
  116. begin
  117. // greater or less/equal to zero
  118. end;
  119. }
  120. 3:
  121. begin
  122. // equal/not equal to zero (the xori remains in the latter case;
  123. // there's a more optimal sequence without it, but needs extra
  124. // register)
  125. p.opcode := A_CNTLZW;
  126. p.loadreg(1,p.oper[0]^.reg);
  127. p.loadreg(0,next1.oper[0]^.reg);
  128. next1.ops := 3;
  129. next1.opcode := A_SRWI;
  130. next1.loadreg(1,next1.oper[0]^.reg);
  131. next1.loadconst(2,5);
  132. asml.remove(next2);
  133. next2.free;
  134. end;
  135. else
  136. result := false;
  137. end;
  138. end;
  139. function TCpuAsmOptimizer.PeepHoleOptPass1Cpu(var p: tai): boolean;
  140. var
  141. next1, next2: tai;
  142. l1, l2: longint;
  143. begin
  144. result := false;
  145. case p.typ of
  146. ait_instruction:
  147. begin
  148. case taicpu(p).opcode of
  149. A_CMPWI,
  150. A_CMPLWI:
  151. begin
  152. if (taicpu(p).oper[1]^.typ = top_const) and
  153. (taicpu(p).oper[1]^.val = 0) and
  154. getnextinstruction(p,next1) and
  155. (next1.typ = ait_instruction) and
  156. (taicpu(next1).opcode = A_MFCR) and
  157. getnextinstruction(next1,next2) and
  158. (taicpu(next2).opcode = A_RLWINM) and
  159. (taicpu(next2).oper[0]^.reg = taicpu(next2).oper[1]^.reg) and
  160. (taicpu(next2).oper[0]^.reg = taicpu(next1).oper[0]^.reg) and
  161. (taicpu(next2).oper[3]^.val = 31) and
  162. (taicpu(next2).oper[4]^.val = 31) and
  163. cmpi_mfcr_opt(taicpu(p),taicpu(next1),taicpu(next2)) then
  164. result := true;
  165. end;
  166. { seems the register allocator doesn't generate superfluous fmr's }
  167. { A_FMR, }
  168. A_MR:
  169. begin
  170. if getnextinstruction(p,next1) and
  171. (next1.typ = ait_instruction) and
  172. (calculation_target_op0[taicpu(next1).opcode] <> a_none) and
  173. (taicpu(next1).oper[0]^.reg = taicpu(p).oper[0]^.reg) then
  174. begin
  175. for l1 := 1 to taicpu(next1).ops - 1 do
  176. if (taicpu(next1).oper[l1]^.typ = top_reg) and
  177. (taicpu(next1).oper[l1]^.reg = taicpu(p).oper[0]^.reg) then
  178. taicpu(next1).loadreg(l1,taicpu(p).oper[1]^.reg);
  179. asml.remove(p);
  180. p.free;
  181. p := next1;
  182. result := true;
  183. end;
  184. end;
  185. A_SLWI:
  186. begin
  187. if getnextinstruction(p,next1) and
  188. (next1.typ = ait_instruction) and
  189. (taicpu(next1).opcode = A_RLWINM) and
  190. (taicpu(next1).oper[0]^.reg = taicpu(p).oper[0]^.reg) and
  191. (taicpu(next1).oper[1]^.reg = taicpu(p).oper[0]^.reg) then
  192. begin
  193. if (taicpu(next1).oper[2]^.val = 0) then
  194. begin
  195. { convert slwi to rlwinm and see if the rlwinm }
  196. { optimization can do something with it }
  197. taicpu(p).opcode := A_RLWINM;
  198. taicpu(p).ops := 5;
  199. taicpu(p).loadconst(2,taicpu(p).oper[2]^.val);
  200. taicpu(p).loadconst(3,0);
  201. taicpu(p).loadconst(4,31-taicpu(p).oper[2]^.val);
  202. result := true;
  203. end;
  204. end;
  205. end;
  206. A_SRWI:
  207. begin
  208. if getnextinstruction(p,next1) and
  209. (next1.typ = ait_instruction) and
  210. ((taicpu(next1).opcode = A_SLWI) or
  211. (taicpu(next1).opcode = A_RLWINM)) and
  212. (taicpu(next1).oper[0]^.reg = taicpu(p).oper[0]^.reg) and
  213. (taicpu(next1).oper[1]^.reg = taicpu(p).oper[0]^.reg) then
  214. case taicpu(next1).opcode of
  215. A_SLWI:
  216. begin
  217. taicpu(p).opcode := A_RLWINM;
  218. taicpu(p).ops := 5;
  219. taicpu(p).loadconst(2,taicpu(next1).oper[2]^.val-taicpu(p).oper[2]^.val);
  220. if (taicpu(p).oper[2]^.val < 0) then
  221. begin
  222. taicpu(p).loadconst(3,-taicpu(p).oper[2]^.val);
  223. taicpu(p).loadconst(4,31-taicpu(next1).oper[2]^.val);
  224. inc(taicpu(p).oper[2]^.val,32);
  225. end
  226. else
  227. begin
  228. taicpu(p).loadconst(3,0);
  229. taicpu(p).loadconst(4,31-taicpu(next1).oper[2]^.val);
  230. end;
  231. asml.remove(next1);
  232. next1.free;
  233. result := true;
  234. end;
  235. A_RLWINM:
  236. begin
  237. if (taicpu(next1).oper[2]^.val = 0) then
  238. begin
  239. { convert srwi to rlwinm and see if the rlwinm }
  240. { optimization can do something with it }
  241. taicpu(p).opcode := A_RLWINM;
  242. taicpu(p).ops := 5;
  243. taicpu(p).loadconst(3,taicpu(p).oper[2]^.val);
  244. taicpu(p).loadconst(4,31);
  245. taicpu(p).loadconst(2,(32-taicpu(p).oper[2]^.val) and 31);
  246. result := true;
  247. end;
  248. end;
  249. end;
  250. end;
  251. A_RLWINM:
  252. begin
  253. if getnextinstruction(p,next1) and
  254. (next1.typ = ait_instruction) and
  255. (taicpu(next1).opcode = A_RLWINM) and
  256. (taicpu(next1).oper[0]^.reg = taicpu(p).oper[0]^.reg) and
  257. // both source and target of next1 must equal target of p
  258. (taicpu(next1).oper[1]^.reg = taicpu(p).oper[0]^.reg) and
  259. (taicpu(next1).oper[2]^.val = 0) then
  260. begin
  261. l1 := taicpu(p).oper[4]^.val;
  262. if (l1 < taicpu(p).oper[3]^.val) then
  263. inc(l1,32);
  264. l2 := taicpu(next1).oper[4]^.val;
  265. if (l2 < taicpu(next1).oper[3]^.val) then
  266. inc(l2,32);
  267. if (taicpu(p).oper[3]^.val > l2) or
  268. (taicpu(next1).oper[3]^.val > l1) then
  269. begin
  270. // masks have no bits in common
  271. taicpu(p).opcode := A_LI;
  272. taicpu(p).loadconst(1,0);
  273. taicpu(p).clearop(2);
  274. taicpu(p).clearop(3);
  275. taicpu(p).clearop(4);
  276. taicpu(p).ops := 2;
  277. taicpu(p).opercnt := 2;
  278. asml.remove(next1);
  279. next1.free;
  280. end
  281. else
  282. // some of the cases with l1>32 or l2>32 can be
  283. // optimized, but others can't (like 19,17 and 25,23)
  284. if (l1 < 32) and
  285. (l2 < 32) then
  286. begin
  287. taicpu(p).oper[3]^.val := max(taicpu(p).oper[3]^.val,taicpu(next1).oper[3]^.val);
  288. taicpu(p).oper[4]^.val := min(taicpu(p).oper[4]^.val,taicpu(next1).oper[4]^.val);
  289. asml.remove(next1);
  290. next1.free;
  291. result := true;
  292. end;
  293. end;
  294. end;
  295. end;
  296. end;
  297. end;
  298. end;
  299. const
  300. modifyflags: array[tasmop] of tasmop =
  301. (a_none, a_add_, a_add_, a_addo_, a_addo_, a_addc_, a_addc_, a_addco_, a_addco_,
  302. a_adde_, a_adde_, a_addeo_, a_addeo_, {a_addi could be addic_ if sure doesn't disturb carry} a_none, a_addic_, a_addic_, a_none,
  303. a_addme_, a_addme_, a_addmeo_, a_addmeo_, a_addze_, a_addze_, a_addzeo_,
  304. a_addzeo_, a_and_, a_and_, a_andc_, a_andc_, a_andi_, a_andis_, a_none,
  305. a_none, a_none, a_none, a_none, a_none, a_none, a_none, a_none, a_none, a_none,
  306. a_none, a_none, a_none, a_none, a_none, a_cntlzw_, a_cntlzw_, a_none,
  307. a_none, a_none, a_none, a_none, a_none, a_none, a_none, a_none,
  308. a_none, a_none, a_none, a_none, a_none, a_none, a_divw_, a_divw_, a_divwo_, a_divwo_,
  309. a_divwu_, a_divwu_, a_divwuo_, a_divwuo_, a_none, a_none, a_none, a_eqv_,
  310. a_eqv_, a_extsb_, a_extsb_, a_extsh_, a_extsh_, a_none, a_none, a_none,
  311. a_none, a_none, a_none, a_none, a_none, a_none, a_none, a_none,
  312. a_none, a_none, a_none, a_none, a_none, a_none, a_none, a_none,
  313. a_none, a_none, a_none, a_none, a_none, a_none, a_none, a_none,
  314. a_none, a_none, a_none, a_none, a_none, a_none, a_none,
  315. a_none, a_none, a_none, a_none, a_none, a_none,
  316. a_none, a_none, a_none, a_none, a_none, a_none, a_none,
  317. a_none, a_none, a_none, a_none, a_none, a_none, a_none, a_none,
  318. a_none, a_none, a_none, a_none, a_none, a_none, a_none, a_none,
  319. a_none, a_none, a_none, a_none, a_none, a_none, a_none, a_none, a_none,
  320. a_none, a_none, a_none, a_none, a_none, a_none, a_none, a_none, a_none,
  321. a_none, a_none, a_none, a_none, a_none, a_none, a_none, a_none, a_none,
  322. a_none, a_none, a_none, a_mffs, a_mffs_, a_mfmsr, a_mfspr, a_mfsr,
  323. a_mfsrin, a_mftb, a_mtcrf, a_none, a_none, a_none, a_none,
  324. a_none, a_none, a_none, a_none, a_none, a_none, a_mulhw_,
  325. a_mulhw_, a_mulhwu_, a_mulhwu_, a_none, a_mullw_, a_mullw_, a_mullwo_,
  326. a_mullwo_, a_nand_, a_nand_, a_neg_, a_neg_, a_nego_, a_nego_, a_nor_, a_nor_,
  327. a_or_, a_or_, a_orc_, a_orc_, a_none, a_none, a_none, a_rlwimi_, a_rlwimi_,
  328. a_rlwinm_, a_rlwinm_, a_rlwnm_, a_rlwnm_, a_none, a_slw_, a_slw_, a_sraw_, a_sraw_,
  329. a_srawi_, a_srawi_,a_srw_, a_srw_, a_none, a_none, a_none, a_none, a_none,
  330. a_none, a_none, a_none, a_none, a_none, a_none, a_none, a_none,
  331. a_none, a_none, a_none, a_none, a_none, a_none, a_none, a_none, a_none,
  332. a_none, a_none, a_none, a_none, a_none, a_subf_, a_subf_, a_subfo_,
  333. a_subfo_, a_subfc_, a_subfc_, a_subfco_, a_subfco_, a_subfe_, a_subfe_,
  334. a_subfeo_, a_subfeo_, a_none, a_subfme_, a_subfme_, a_subfmeo_, a_subfmeo_,
  335. a_subfze_, a_subfze_, a_subfzeo_, a_subfzeo_, a_none, a_none, a_none,
  336. a_none, a_none, a_none, a_xor_, a_xor_, a_none, a_none,
  337. { simplified mnemonics }
  338. a_none, a_none, a_subic_, a_subic_, a_sub_, a_sub_, a_subo_, a_subo_,
  339. a_subc_, a_subc_, a_subco_, a_subco_, a_none, a_none, a_none, a_none,
  340. a_extlwi_, a_extlwi_, a_extrwi_, a_extrwi_, a_inslwi_, a_inslwi_, a_insrwi_,
  341. a_insrwi_, a_rotlwi_, a_rotlwi_, a_rotlw_, a_rotlw_, a_slwi_, a_slwi_,
  342. a_srwi_, a_srwi_, a_clrlwi_, a_clrlwi_, a_clrrwi_, a_clrrwi_, a_clrslwi_,
  343. a_clrslwi_, a_none, a_none, a_none, a_none, a_none, a_none, a_none,
  344. a_none, a_none {move to special prupose reg}, a_none {move from special purpose reg},
  345. a_none, a_none, a_none, a_none, a_mr_, a_mr_, a_not_, a_not_, a_none, a_none, a_none,
  346. a_none, a_none, a_none);
  347. function changetomodifyflags(p: taicpu): boolean;
  348. begin
  349. result := false;
  350. if (modifyflags[p.opcode] <> a_none) then
  351. begin
  352. p.opcode := modifyflags[p.opcode];
  353. result := true;
  354. end;
  355. end;
  356. function TCpuAsmOptimizer.PostPeepHoleOptsCpu(var p: tai): boolean;
  357. var
  358. next1: tai;
  359. begin
  360. result := false;
  361. case p.typ of
  362. ait_instruction:
  363. begin
  364. case taicpu(p).opcode of
  365. A_RLWINM_:
  366. begin
  367. // rlwinm_ is cracked on the G5, andi_/andis_ aren't
  368. if (taicpu(p).oper[2]^.val = 0) then
  369. if (taicpu(p).oper[3]^.val < 16) and
  370. (taicpu(p).oper[4]^.val < 16) then
  371. begin
  372. taicpu(p).opcode := A_ANDIS_;
  373. taicpu(p).oper[2]^.val :=
  374. ((1 shl (16-taicpu(p).oper[3]^.val)) - 1) and
  375. not((1 shl (15-taicpu(p).oper[4]^.val)) - 1);
  376. taicpu(p).clearop(3);
  377. taicpu(p).clearop(4);
  378. taicpu(p).ops := 3;
  379. taicpu(p).opercnt := 2;
  380. end
  381. else if (taicpu(p).oper[3]^.val >= 16) and
  382. (taicpu(p).oper[4]^.val >= 16) then
  383. begin
  384. taicpu(p).opcode := A_ANDI_;
  385. taicpu(p).oper[2]^.val :=
  386. ((1 shl (32-taicpu(p).oper[3]^.val)) - 1) and
  387. not((1 shl (31-taicpu(p).oper[4]^.val)) - 1);
  388. taicpu(p).clearop(3);
  389. taicpu(p).clearop(4);
  390. taicpu(p).ops := 3;
  391. taicpu(p).opercnt := 2;
  392. end;
  393. end;
  394. end;
  395. // change "integer operation with destination reg" followed by a
  396. // comparison to zero of that reg, with a variant of that integer
  397. // operation which sets the flags (if it exists)
  398. if not(result) and
  399. (taicpu(p).ops >= 2) and
  400. (taicpu(p).oper[0]^.typ = top_reg) and
  401. (taicpu(p).oper[1]^.typ = top_reg) and
  402. getnextinstruction(p,next1) and
  403. (next1.typ = ait_instruction) and
  404. (taicpu(next1).opcode = A_CMPWI) and
  405. // make sure it the result goes to cr0
  406. (((taicpu(next1).ops = 2) and
  407. (taicpu(next1).oper[1]^.val = 0) and
  408. (taicpu(next1).oper[0]^.reg = taicpu(p).oper[0]^.reg)) or
  409. ((taicpu(next1).ops = 3) and
  410. (taicpu(next1).oper[2]^.val = 0) and
  411. (taicpu(next1).oper[0]^.typ = top_reg) and
  412. (getsupreg(taicpu(next1).oper[0]^.reg) = RS_CR0) and
  413. (taicpu(next1).oper[1]^.reg = taicpu(p).oper[0]^.reg))) and
  414. changetomodifyflags(taicpu(p)) then
  415. begin
  416. asml.remove(next1);
  417. next1.free;
  418. result := true;
  419. end;
  420. end;
  421. end;
  422. end;
  423. begin
  424. casmoptimizer:=TCpuAsmOptimizer;
  425. End.