aoptcpu.pas 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120
  1. {
  2. Copyright (c) 1998-2002 by Jonas Maebe, member of the Free Pascal
  3. Development Team
  4. This unit implements the ARM 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. {$i fpcdefs.inc}
  20. { $define DEBUG_AOPTCPU}
  21. Interface
  22. uses cpubase,cgbase,aasmtai,aopt,AoptObj,aoptcpub;
  23. Type
  24. TCpuAsmOptimizer = class(TAsmOptimizer)
  25. { outputs a debug message into the assembler file }
  26. procedure DebugMsg(const s: string; p: tai);
  27. Function GetNextInstructionUsingReg(Current: tai; Var Next: tai;reg : TRegister): Boolean;
  28. function RegInInstruction(Reg: TRegister; p1: tai): Boolean; override;
  29. function RegLoadedWithNewValue(reg : tregister; hp : tai) : boolean; override;
  30. function InstructionLoadsFromReg(const reg : TRegister; const hp : tai) : boolean; override;
  31. { uses the same constructor as TAopObj }
  32. function PeepHoleOptPass1Cpu(var p: tai): boolean; override;
  33. procedure PeepHoleOptPass2;override;
  34. End;
  35. Implementation
  36. uses
  37. cutils,
  38. verbose,
  39. cpuinfo,
  40. aasmbase,aasmcpu,aasmdata,
  41. aoptutils,
  42. globals,globtype,
  43. cgutils;
  44. type
  45. TAsmOpSet = set of TAsmOp;
  46. function CanBeCond(p : tai) : boolean;
  47. begin
  48. result:=(p.typ=ait_instruction) and (taicpu(p).condition=C_None);
  49. end;
  50. function RefsEqual(const r1, r2: treference): boolean;
  51. begin
  52. refsequal :=
  53. (r1.offset = r2.offset) and
  54. (r1.base = r2.base) and
  55. (r1.index = r2.index) and (r1.scalefactor = r2.scalefactor) and
  56. (r1.symbol=r2.symbol) and (r1.refaddr = r2.refaddr) and
  57. (r1.relsymbol = r2.relsymbol) and
  58. (r1.addressmode = r2.addressmode) and
  59. (r1.volatility=[]) and
  60. (r2.volatility=[]);
  61. end;
  62. function MatchOperand(const oper1: TOper; const oper2: TOper): boolean; inline;
  63. begin
  64. result:=oper1.typ=oper2.typ;
  65. if result then
  66. case oper1.typ of
  67. top_const:
  68. Result:=oper1.val = oper2.val;
  69. top_reg:
  70. Result:=oper1.reg = oper2.reg;
  71. top_ref:
  72. Result:=RefsEqual(oper1.ref^, oper2.ref^);
  73. else Result:=false;
  74. end
  75. end;
  76. function MatchOperand(const oper: TOper; const reg: TRegister): boolean; inline;
  77. begin
  78. result := (oper.typ = top_reg) and (oper.reg = reg);
  79. end;
  80. function MatchInstruction(const instr: tai; const op: TAsmOp): boolean;
  81. begin
  82. result :=
  83. (instr.typ = ait_instruction) and
  84. (taicpu(instr).opcode = op);
  85. end;
  86. function MatchInstruction(const instr: tai; const ops: TAsmOpSet): boolean;
  87. begin
  88. result :=
  89. (instr.typ = ait_instruction) and
  90. (taicpu(instr).opcode in ops);
  91. end;
  92. function MatchInstruction(const instr: tai; const ops: TAsmOpSet;opcount : byte): boolean;
  93. begin
  94. result :=
  95. (instr.typ = ait_instruction) and
  96. (taicpu(instr).opcode in ops) and
  97. (taicpu(instr).ops=opcount);
  98. end;
  99. {$ifdef DEBUG_AOPTCPU}
  100. procedure TCpuAsmOptimizer.DebugMsg(const s: string;p : tai);
  101. begin
  102. asml.insertbefore(tai_comment.Create(strpnew(s)), p);
  103. end;
  104. {$else DEBUG_AOPTCPU}
  105. procedure TCpuAsmOptimizer.DebugMsg(const s: string;p : tai);inline;
  106. begin
  107. end;
  108. {$endif DEBUG_AOPTCPU}
  109. function TCpuAsmOptimizer.RegInInstruction(Reg: TRegister; p1: tai): Boolean;
  110. begin
  111. If (p1.typ = ait_instruction) and (taicpu(p1).opcode in [A_MUL,A_MULS,A_FMUL,A_FMULS,A_FMULSU]) and
  112. ((getsupreg(reg)=RS_R0) or (getsupreg(reg)=RS_R1)) then
  113. Result:=true
  114. else if (p1.typ = ait_instruction) and (taicpu(p1).opcode=A_MOVW) and
  115. ((TRegister(ord(taicpu(p1).oper[0]^.reg)+1)=reg) or (TRegister(ord(taicpu(p1).oper[1]^.reg)+1)=reg) or
  116. (taicpu(p1).oper[0]^.reg=reg) or (taicpu(p1).oper[1]^.reg=reg)) then
  117. Result:=true
  118. else
  119. Result:=inherited RegInInstruction(Reg, p1);
  120. end;
  121. function TCpuAsmOptimizer.GetNextInstructionUsingReg(Current: tai;
  122. var Next: tai; reg: TRegister): Boolean;
  123. begin
  124. Next:=Current;
  125. repeat
  126. Result:=GetNextInstruction(Next,Next);
  127. until not(cs_opt_level3 in current_settings.optimizerswitches) or not(Result) or (Next.typ<>ait_instruction) or (RegInInstruction(reg,Next)) or
  128. (is_calljmp(taicpu(Next).opcode));
  129. end;
  130. function TCpuAsmOptimizer.RegLoadedWithNewValue(reg: tregister; hp: tai): boolean;
  131. var
  132. p: taicpu;
  133. begin
  134. if not assigned(hp) or
  135. (hp.typ <> ait_instruction) then
  136. begin
  137. Result := false;
  138. exit;
  139. end;
  140. p := taicpu(hp);
  141. Result := ((p.opcode in [A_LDI,A_MOV,A_LDS]) and (reg=p.oper[0]^.reg) and ((p.oper[1]^.typ<>top_reg) or (reg<>p.oper[0]^.reg))) or
  142. ((p.opcode in [A_LD,A_LDD,A_LPM]) and (reg=p.oper[0]^.reg) and not(RegInRef(reg,p.oper[1]^.ref^))) or
  143. ((p.opcode in [A_MOVW]) and ((reg=p.oper[0]^.reg) or (TRegister(ord(reg)+1)=p.oper[0]^.reg)) and not(reg=p.oper[1]^.reg) and not(TRegister(ord(reg)+1)=p.oper[1]^.reg)) or
  144. ((p.opcode in [A_POP]) and (reg=p.oper[0]^.reg));
  145. end;
  146. function TCpuAsmOptimizer.InstructionLoadsFromReg(const reg: TRegister; const hp: tai): boolean;
  147. var
  148. p: taicpu;
  149. i: longint;
  150. begin
  151. Result := false;
  152. if not (assigned(hp) and (hp.typ = ait_instruction)) then
  153. exit;
  154. p:=taicpu(hp);
  155. i:=0;
  156. { we do not care about the stack pointer }
  157. if p.opcode in [A_POP] then
  158. exit;
  159. { first operand only written?
  160. then skip it }
  161. if p.opcode in [A_MOV,A_LD,A_LDD,A_LDS,A_LPM,A_LDI,A_MOVW] then
  162. i:=1;
  163. while i<p.ops do
  164. begin
  165. case p.oper[i]^.typ of
  166. top_reg:
  167. Result := (p.oper[i]^.reg = reg) or
  168. { MOVW }
  169. ((i=1) and (p.opcode=A_MOVW) and (getsupreg(p.oper[0]^.reg)+1=getsupreg(reg)));
  170. top_ref:
  171. Result :=
  172. (p.oper[i]^.ref^.base = reg) or
  173. (p.oper[i]^.ref^.index = reg);
  174. end;
  175. { Bailout if we found something }
  176. if Result then
  177. exit;
  178. Inc(i);
  179. end;
  180. end;
  181. function TCpuAsmOptimizer.PeepHoleOptPass1Cpu(var p: tai): boolean;
  182. var
  183. hp1,hp2,hp3,hp4,hp5: tai;
  184. alloc, dealloc: tai_regalloc;
  185. i: integer;
  186. l: TAsmLabel;
  187. begin
  188. result := false;
  189. case p.typ of
  190. ait_instruction:
  191. begin
  192. {
  193. change
  194. <op> reg,x,y
  195. cp reg,r1
  196. into
  197. <op>s reg,x,y
  198. }
  199. { this optimization can applied only to the currently enabled operations because
  200. the other operations do not update all flags and FPC does not track flag usage }
  201. if MatchInstruction(p, [A_ADC,A_ADD,A_AND,A_ANDI,A_ASR,A_COM,A_DEC,A_EOR,
  202. A_INC,A_LSL,A_LSR,
  203. A_OR,A_ORI,A_ROL,A_ROR,A_SBC,A_SBCI,A_SUB,A_SUBI]) and
  204. GetNextInstruction(p, hp1) and
  205. ((MatchInstruction(hp1, A_CP) and
  206. (((taicpu(p).oper[0]^.reg = taicpu(hp1).oper[0]^.reg) and
  207. (taicpu(hp1).oper[1]^.reg = NR_R1)) or
  208. ((taicpu(p).oper[0]^.reg = taicpu(hp1).oper[1]^.reg) and
  209. (taicpu(hp1).oper[0]^.reg = NR_R1) and
  210. (taicpu(p).opcode in [A_ADC,A_ADD,A_AND,A_ANDI,A_ASR,A_COM,A_EOR,
  211. A_LSL,A_LSR,
  212. A_OR,A_ORI,A_ROL,A_ROR,A_SUB,A_SBI])))) or
  213. (MatchInstruction(hp1, A_CPI) and
  214. (taicpu(p).opcode = A_ANDI) and
  215. (taicpu(p).oper[1]^.typ=top_const) and
  216. (taicpu(hp1).oper[1]^.typ=top_const) and
  217. (taicpu(p).oper[1]^.val=taicpu(hp1).oper[1]^.val))) and
  218. GetNextInstruction(hp1, hp2) and
  219. { be careful here, following instructions could use other flags
  220. however after a jump fpc never depends on the value of flags }
  221. { All above instructions set Z and N according to the following
  222. Z := result = 0;
  223. N := result[31];
  224. EQ = Z=1; NE = Z=0;
  225. MI = N=1; PL = N=0; }
  226. MatchInstruction(hp2, A_BRxx) and
  227. ((taicpu(hp2).condition in [C_EQ,C_NE,C_MI,C_PL]) or
  228. { sub/sbc set all flags }
  229. (taicpu(p).opcode in [A_SUB,A_SBI])){ and
  230. no flag allocation tracking implemented yet on avr
  231. assigned(FindRegDealloc(NR_DEFAULTFLAGS,tai(hp2.Next)))} then
  232. begin
  233. { move flag allocation if possible }
  234. { no flag allocation tracking implemented yet on avr
  235. GetLastInstruction(hp1, hp2);
  236. hp2:=FindRegAlloc(NR_DEFAULTFLAGS,tai(hp2.Next));
  237. if assigned(hp2) then
  238. begin
  239. asml.Remove(hp2);
  240. asml.insertbefore(hp2, p);
  241. end;
  242. }
  243. // If we compare to the same value we are masking then invert the comparison
  244. if (taicpu(hp1).opcode=A_CPI) or
  245. { sub/sbc with reverted? }
  246. ((taicpu(hp1).oper[0]^.reg = NR_R1) and (taicpu(p).opcode in [A_SUB,A_SBI])) then
  247. taicpu(hp2).condition:=inverse_cond(taicpu(hp2).condition);
  248. asml.InsertBefore(tai_regalloc.alloc(NR_DEFAULTFLAGS,p), p);
  249. asml.InsertAfter(tai_regalloc.dealloc(NR_DEFAULTFLAGS,hp2), hp2);
  250. IncludeRegInUsedRegs(NR_DEFAULTFLAGS,UsedRegs);
  251. DebugMsg('Peephole OpCp2Op performed', p);
  252. asml.remove(hp1);
  253. hp1.free;
  254. Result:=true;
  255. end
  256. else
  257. case taicpu(p).opcode of
  258. A_LDI:
  259. begin
  260. { turn
  261. ldi reg0, imm
  262. cp/mov reg1, reg0
  263. dealloc reg0
  264. into
  265. cpi/ldi reg1, imm
  266. }
  267. if MatchOpType(taicpu(p),top_reg,top_const) and
  268. GetNextInstructionUsingReg(p, hp1, taicpu(p).oper[0]^.reg) and
  269. MatchInstruction(hp1,[A_CP,A_MOV],2) and
  270. (not RegModifiedBetween(taicpu(p).oper[0]^.reg, p, hp1)) and
  271. MatchOpType(taicpu(hp1),top_reg,top_reg) and
  272. (getsupreg(taicpu(hp1).oper[0]^.reg) in [16..31]) and
  273. (taicpu(hp1).oper[1]^.reg=taicpu(p).oper[0]^.reg) and
  274. not(MatchOperand(taicpu(hp1).oper[0]^,taicpu(hp1).oper[1]^)) then
  275. begin
  276. TransferUsedRegs(TmpUsedRegs);
  277. if not(RegUsedAfterInstruction(taicpu(hp1).oper[1]^.reg, hp1, TmpUsedRegs)) then
  278. begin
  279. case taicpu(hp1).opcode of
  280. A_CP:
  281. taicpu(hp1).opcode:=A_CPI;
  282. A_MOV:
  283. taicpu(hp1).opcode:=A_LDI;
  284. else
  285. internalerror(2016111901);
  286. end;
  287. taicpu(hp1).loadconst(1, taicpu(p).oper[1]^.val);
  288. alloc:=FindRegAllocBackward(taicpu(p).oper[0]^.reg,tai(p.Previous));
  289. dealloc:=FindRegDeAlloc(taicpu(p).oper[0]^.reg,tai(hp1.Next));
  290. if assigned(alloc) and assigned(dealloc) then
  291. begin
  292. asml.Remove(alloc);
  293. alloc.Free;
  294. asml.Remove(dealloc);
  295. dealloc.Free;
  296. end;
  297. DebugMsg('Peephole LdiMov/Cp2Ldi/Cpi performed', p);
  298. RemoveCurrentP(p);
  299. end;
  300. end;
  301. end;
  302. A_STS:
  303. if (taicpu(p).oper[0]^.ref^.symbol=nil) and
  304. (taicpu(p).oper[0]^.ref^.relsymbol=nil) and
  305. (getsupreg(taicpu(p).oper[0]^.ref^.base)=RS_NO) and
  306. (getsupreg(taicpu(p).oper[0]^.ref^.index)=RS_NO) and
  307. (taicpu(p).oper[0]^.ref^.addressmode=AM_UNCHANGED) and
  308. (taicpu(p).oper[0]^.ref^.offset>=32) and
  309. (taicpu(p).oper[0]^.ref^.offset<=95) then
  310. begin
  311. DebugMsg('Peephole Sts2Out performed', p);
  312. taicpu(p).opcode:=A_OUT;
  313. taicpu(p).loadconst(0,taicpu(p).oper[0]^.ref^.offset-32);
  314. end;
  315. A_LDS:
  316. if (taicpu(p).oper[1]^.ref^.symbol=nil) and
  317. (taicpu(p).oper[1]^.ref^.relsymbol=nil) and
  318. (getsupreg(taicpu(p).oper[1]^.ref^.base)=RS_NO) and
  319. (getsupreg(taicpu(p).oper[1]^.ref^.index)=RS_NO) and
  320. (taicpu(p).oper[1]^.ref^.addressmode=AM_UNCHANGED) and
  321. (taicpu(p).oper[1]^.ref^.offset>=32) and
  322. (taicpu(p).oper[1]^.ref^.offset<=95) then
  323. begin
  324. DebugMsg('Peephole Lds2In performed', p);
  325. taicpu(p).opcode:=A_IN;
  326. taicpu(p).loadconst(1,taicpu(p).oper[1]^.ref^.offset-32);
  327. end;
  328. A_IN:
  329. if GetNextInstruction(p,hp1) then
  330. begin
  331. {
  332. in rX,Y
  333. ori rX,n
  334. out Y,rX
  335. into
  336. sbi rX,lg(n)
  337. }
  338. if (taicpu(p).oper[1]^.val<=31) and
  339. MatchInstruction(hp1,A_ORI) and
  340. (taicpu(hp1).oper[0]^.reg=taicpu(p).oper[0]^.reg) and
  341. (PopCnt(byte(taicpu(hp1).oper[1]^.val))=1) and
  342. GetNextInstruction(hp1,hp2) and
  343. MatchInstruction(hp2,A_OUT) and
  344. MatchOperand(taicpu(hp2).oper[1]^,taicpu(p).oper[0]^) and
  345. MatchOperand(taicpu(hp2).oper[0]^,taicpu(p).oper[1]^) then
  346. begin
  347. DebugMsg('Peephole InOriOut2Sbi performed', p);
  348. taicpu(p).opcode:=A_SBI;
  349. taicpu(p).loadconst(0,taicpu(p).oper[1]^.val);
  350. taicpu(p).loadconst(1,BsrByte(taicpu(hp1).oper[1]^.val));
  351. asml.Remove(hp1);
  352. hp1.Free;
  353. asml.Remove(hp2);
  354. hp2.Free;
  355. result:=true;
  356. end
  357. {
  358. in rX,Y
  359. andi rX,not(n)
  360. out Y,rX
  361. into
  362. cbi rX,lg(n)
  363. }
  364. else if (taicpu(p).oper[1]^.val<=31) and
  365. MatchInstruction(hp1,A_ANDI) and
  366. (taicpu(hp1).oper[0]^.reg=taicpu(p).oper[0]^.reg) and
  367. (PopCnt(byte(not(taicpu(hp1).oper[1]^.val)))=1) and
  368. GetNextInstruction(hp1,hp2) and
  369. MatchInstruction(hp2,A_OUT) and
  370. MatchOperand(taicpu(hp2).oper[1]^,taicpu(p).oper[0]^) and
  371. MatchOperand(taicpu(hp2).oper[0]^,taicpu(p).oper[1]^) then
  372. begin
  373. DebugMsg('Peephole InAndiOut2Cbi performed', p);
  374. taicpu(p).opcode:=A_CBI;
  375. taicpu(p).loadconst(0,taicpu(p).oper[1]^.val);
  376. taicpu(p).loadconst(1,BsrByte(not(taicpu(hp1).oper[1]^.val)));
  377. asml.Remove(hp1);
  378. hp1.Free;
  379. asml.Remove(hp2);
  380. hp2.Free;
  381. result:=true;
  382. end
  383. {
  384. in rX,Y
  385. andi rX,n
  386. breq/brne L1
  387. into
  388. sbis/sbic Y,lg(n)
  389. jmp L1
  390. .Ltemp:
  391. }
  392. else if (taicpu(p).oper[1]^.val<=31) and
  393. MatchInstruction(hp1,A_ANDI) and
  394. (taicpu(hp1).oper[0]^.reg=taicpu(p).oper[0]^.reg) and
  395. (PopCnt(byte(taicpu(hp1).oper[1]^.val))=1) and
  396. GetNextInstruction(hp1,hp2) and
  397. MatchInstruction(hp2,A_BRxx) and
  398. (taicpu(hp2).condition in [C_EQ,C_NE]) then
  399. begin
  400. if taicpu(hp2).condition=C_EQ then
  401. taicpu(p).opcode:=A_SBIS
  402. else
  403. taicpu(p).opcode:=A_SBIC;
  404. DebugMsg('Peephole InAndiBrx2SbixJmp performed', p);
  405. taicpu(p).loadconst(0,taicpu(p).oper[1]^.val);
  406. taicpu(p).loadconst(1,BsrByte(taicpu(hp1).oper[1]^.val));
  407. asml.Remove(hp1);
  408. hp1.Free;
  409. taicpu(hp2).condition:=C_None;
  410. if CPUAVR_HAS_JMP_CALL in cpu_capabilities[current_settings.cputype] then
  411. taicpu(hp2).opcode:=A_JMP
  412. else
  413. taicpu(hp2).opcode:=A_RJMP;
  414. current_asmdata.getjumplabel(l);
  415. l.increfs;
  416. asml.InsertAfter(tai_label.create(l), hp2);
  417. result:=true;
  418. end;
  419. end;
  420. A_SBRS,
  421. A_SBRC:
  422. begin
  423. {
  424. Turn
  425. in rx, y
  426. sbr* rx, z
  427. Into
  428. sbi* y, z
  429. }
  430. if (taicpu(p).ops=2) and
  431. (taicpu(p).oper[0]^.typ=top_reg) and
  432. assigned(FindRegDeAlloc(taicpu(p).oper[0]^.reg,tai(p.next))) and
  433. GetLastInstruction(p,hp1) and
  434. (hp1.typ=ait_instruction) and
  435. (taicpu(hp1).opcode=A_IN) and
  436. (taicpu(hp1).ops=2) and
  437. (taicpu(hp1).oper[1]^.typ=top_const) and
  438. (taicpu(hp1).oper[1]^.val in [0..31]) and
  439. MatchOperand(taicpu(hp1).oper[0]^,taicpu(p).oper[0]^.reg) and
  440. (not RegModifiedBetween(taicpu(p).oper[0]^.reg, hp1, p)) then
  441. begin
  442. if taicpu(p).opcode=A_SBRS then
  443. taicpu(p).opcode:=A_SBIS
  444. else
  445. taicpu(p).opcode:=A_SBIC;
  446. taicpu(p).loadconst(0, taicpu(hp1).oper[1]^.val);
  447. DebugMsg('Peephole InSbrx2Sbix performed', p);
  448. asml.Remove(hp1);
  449. hp1.free;
  450. result:=true;
  451. end;
  452. end;
  453. A_ANDI:
  454. begin
  455. {
  456. Turn
  457. andi rx, #pow2
  458. brne l
  459. <op>
  460. l:
  461. Into
  462. sbrs rx, #(1 shl imm)
  463. <op>
  464. l:
  465. }
  466. if (taicpu(p).ops=2) and
  467. (taicpu(p).oper[1]^.typ=top_const) and
  468. ispowerof2(taicpu(p).oper[1]^.val,i) and
  469. assigned(FindRegDeAlloc(taicpu(p).oper[0]^.reg,tai(p.next))) and
  470. GetNextInstruction(p,hp1) and
  471. (hp1.typ=ait_instruction) and
  472. (taicpu(hp1).opcode=A_BRxx) and
  473. (taicpu(hp1).condition in [C_EQ,C_NE]) and
  474. (taicpu(hp1).ops>0) and
  475. (taicpu(hp1).oper[0]^.typ = top_ref) and
  476. (taicpu(hp1).oper[0]^.ref^.symbol is TAsmLabel) and
  477. GetNextInstruction(hp1,hp2) and
  478. (hp2.typ=ait_instruction) and
  479. GetNextInstruction(hp2,hp3) and
  480. (hp3.typ=ait_label) and
  481. (taicpu(hp1).oper[0]^.ref^.symbol=tai_label(hp3).labsym) then
  482. begin
  483. DebugMsg('Peephole AndiBr2Sbr performed', p);
  484. taicpu(p).oper[1]^.val:=i;
  485. if taicpu(hp1).condition=C_NE then
  486. taicpu(p).opcode:=A_SBRS
  487. else
  488. taicpu(p).opcode:=A_SBRC;
  489. asml.Remove(hp1);
  490. hp1.free;
  491. result:=true;
  492. end
  493. {
  494. Remove
  495. andi rx, #y
  496. dealloc rx
  497. }
  498. else if (taicpu(p).ops=2) and
  499. (taicpu(p).oper[0]^.typ=top_reg) and
  500. assigned(FindRegDeAlloc(taicpu(p).oper[0]^.reg,tai(p.next))) and
  501. (assigned(FindRegDeAlloc(NR_DEFAULTFLAGS,tai(p.Next))) or
  502. (not RegInUsedRegs(NR_DEFAULTFLAGS,UsedRegs))) then
  503. begin
  504. DebugMsg('Redundant Andi removed', p);
  505. result:=RemoveCurrentP(p);
  506. end;
  507. end;
  508. A_ADD:
  509. begin
  510. if (taicpu(p).oper[1]^.reg=NR_R1) and
  511. GetNextInstruction(p, hp1) and
  512. MatchInstruction(hp1,A_ADC) then
  513. begin
  514. DebugMsg('Peephole AddAdc2Add performed', p);
  515. result:=RemoveCurrentP(p);
  516. end;
  517. end;
  518. A_SUB:
  519. begin
  520. if (taicpu(p).oper[1]^.reg=NR_R1) and
  521. GetNextInstruction(p, hp1) and
  522. MatchInstruction(hp1,A_SBC) then
  523. begin
  524. DebugMsg('Peephole SubSbc2Sub performed', p);
  525. taicpu(hp1).opcode:=A_SUB;
  526. result:=RemoveCurrentP(p);
  527. end;
  528. end;
  529. A_CLR:
  530. begin
  531. { turn the common
  532. clr rX
  533. mov/ld rX, rY
  534. into
  535. mov/ld rX, rY
  536. }
  537. if (taicpu(p).ops=1) and
  538. (taicpu(p).oper[0]^.typ=top_reg) and
  539. GetNextInstructionUsingReg(p, hp1, taicpu(p).oper[0]^.reg) and
  540. (not RegModifiedBetween(taicpu(p).oper[0]^.reg, p, hp1)) and
  541. (hp1.typ=ait_instruction) and
  542. (taicpu(hp1).opcode in [A_MOV,A_LD]) and
  543. (taicpu(hp1).ops>0) and
  544. (taicpu(hp1).oper[0]^.typ=top_reg) and
  545. (taicpu(hp1).oper[0]^.reg=taicpu(p).oper[0]^.reg) then
  546. begin
  547. DebugMsg('Peephole ClrMov2Mov performed', p);
  548. result:=RemoveCurrentP(p);
  549. end
  550. { turn
  551. clr rX
  552. ...
  553. adc rY, rX
  554. into
  555. ...
  556. adc rY, r1
  557. }
  558. else if (taicpu(p).ops=1) and
  559. (taicpu(p).oper[0]^.typ=top_reg) and
  560. GetNextInstructionUsingReg(p, hp1, taicpu(p).oper[0]^.reg) and
  561. (not RegModifiedBetween(taicpu(p).oper[0]^.reg, p, hp1)) and
  562. (hp1.typ=ait_instruction) and
  563. (taicpu(hp1).opcode in [A_ADC,A_SBC]) and
  564. (taicpu(hp1).ops=2) and
  565. (taicpu(hp1).oper[1]^.typ=top_reg) and
  566. (taicpu(hp1).oper[1]^.reg=taicpu(p).oper[0]^.reg) and
  567. (taicpu(hp1).oper[0]^.reg<>taicpu(p).oper[0]^.reg) and
  568. assigned(FindRegDeAlloc(taicpu(p).oper[0]^.reg,tai(hp1.Next))) then
  569. begin
  570. DebugMsg('Peephole ClrAdc2Adc performed', p);
  571. taicpu(hp1).oper[1]^.reg:=NR_R1;
  572. alloc:=FindRegAllocBackward(taicpu(p).oper[0]^.reg,tai(p.Previous));
  573. dealloc:=FindRegDeAlloc(taicpu(p).oper[0]^.reg,tai(hp1.Next));
  574. if assigned(alloc) and assigned(dealloc) then
  575. begin
  576. asml.Remove(alloc);
  577. alloc.Free;
  578. asml.Remove(dealloc);
  579. dealloc.Free;
  580. end;
  581. result:=RemoveCurrentP(p);
  582. end;
  583. end;
  584. A_PUSH:
  585. begin
  586. { turn
  587. push reg0
  588. push reg1
  589. pop reg3
  590. pop reg2
  591. into
  592. movw reg2,reg0
  593. or
  594. mov reg3,reg1
  595. mov reg2,reg0
  596. }
  597. if GetNextInstruction(p,hp1) and
  598. MatchInstruction(hp1,A_PUSH) and
  599. GetNextInstruction(hp1,hp2) and
  600. MatchInstruction(hp2,A_POP) and
  601. GetNextInstruction(hp2,hp3) and
  602. MatchInstruction(hp3,A_POP) then
  603. begin
  604. if (getsupreg(taicpu(hp1).oper[0]^.reg)=getsupreg(taicpu(p).oper[0]^.reg)+1) and
  605. ((getsupreg(taicpu(p).oper[0]^.reg) mod 2)=0) and
  606. (getsupreg(taicpu(hp2).oper[0]^.reg)=getsupreg(taicpu(hp3).oper[0]^.reg)+1) and
  607. ((getsupreg(taicpu(hp3).oper[0]^.reg) mod 2)=0) then
  608. begin
  609. DebugMsg('Peephole PushPushPopPop2Movw performed', p);
  610. taicpu(hp3).ops:=2;
  611. taicpu(hp3).opcode:=A_MOVW;
  612. taicpu(hp3).loadreg(1, taicpu(p).oper[0]^.reg);
  613. RemoveCurrentP(p);
  614. RemoveCurrentP(p);
  615. result:=RemoveCurrentP(p);
  616. end
  617. else
  618. begin
  619. DebugMsg('Peephole PushPushPopPop2MovMov performed', p);
  620. taicpu(p).ops:=2;
  621. taicpu(p).opcode:=A_MOV;
  622. taicpu(hp1).ops:=2;
  623. taicpu(hp1).opcode:=A_MOV;
  624. taicpu(p).loadreg(1, taicpu(p).oper[0]^.reg);
  625. taicpu(p).loadreg(0, taicpu(hp3).oper[0]^.reg);
  626. taicpu(hp1).loadreg(1, taicpu(hp1).oper[0]^.reg);
  627. taicpu(hp1).loadreg(0, taicpu(hp2).oper[0]^.reg);
  628. { life range of reg2 and reg3 is increased, fix register allocation entries }
  629. TransferUsedRegs(TmpUsedRegs);
  630. UpdateUsedRegs(TmpUsedRegs,tai(p.Next));
  631. AllocRegBetween(taicpu(hp2).oper[0]^.reg,hp1,hp2,TmpUsedRegs);
  632. TransferUsedRegs(TmpUsedRegs);
  633. AllocRegBetween(taicpu(hp3).oper[0]^.reg,p,hp3,TmpUsedRegs);
  634. IncludeRegInUsedRegs(taicpu(hp3).oper[0]^.reg,UsedRegs);
  635. UpdateUsedRegs(tai(p.Next));
  636. asml.Remove(hp2);
  637. hp2.Free;
  638. asml.Remove(hp3);
  639. hp3.Free;
  640. result:=true;
  641. end
  642. end;
  643. end;
  644. A_CALL:
  645. if (cs_opt_level4 in current_settings.optimizerswitches) and
  646. GetNextInstruction(p,hp1) and
  647. MatchInstruction(hp1,A_RET) then
  648. begin
  649. DebugMsg('Peephole CallReg2Jmp performed', p);
  650. taicpu(p).opcode:=A_JMP;
  651. asml.Remove(hp1);
  652. hp1.Free;
  653. result:=true;
  654. end;
  655. A_RCALL:
  656. if (cs_opt_level4 in current_settings.optimizerswitches) and
  657. GetNextInstruction(p,hp1) and
  658. MatchInstruction(hp1,A_RET) then
  659. begin
  660. DebugMsg('Peephole RCallReg2RJmp performed', p);
  661. taicpu(p).opcode:=A_RJMP;
  662. asml.Remove(hp1);
  663. hp1.Free;
  664. result:=true;
  665. end;
  666. A_MOV:
  667. begin
  668. { change
  669. mov reg0, reg1
  670. dealloc reg0
  671. into
  672. dealloc reg0
  673. }
  674. if MatchOpType(taicpu(p),top_reg,top_reg) then
  675. begin
  676. TransferUsedRegs(TmpUsedRegs);
  677. UpdateUsedRegs(TmpUsedRegs,tai(p.Next));
  678. if not(RegInUsedRegs(taicpu(p).oper[0]^.reg,TmpUsedRegs)) and
  679. { reg. allocation information before calls is not perfect, so don't do this before
  680. calls/icalls }
  681. GetNextInstruction(p,hp1) and
  682. not(MatchInstruction(hp1,[A_CALL,A_RCALL])) then
  683. begin
  684. DebugMsg('Peephole Mov2Nop performed', p);
  685. result:=RemoveCurrentP(p);
  686. exit;
  687. end;
  688. end;
  689. { turn
  690. mov reg0, reg1
  691. <op> reg2,reg0
  692. dealloc reg0
  693. into
  694. <op> reg2,reg1
  695. }
  696. if MatchOpType(taicpu(p),top_reg,top_reg) and
  697. GetNextInstructionUsingReg(p,hp1,taicpu(p).oper[0]^.reg) and
  698. (not RegModifiedBetween(taicpu(p).oper[1]^.reg, p, hp1)) and
  699. (MatchInstruction(hp1,[A_PUSH,A_MOV,A_CP,A_CPC,A_ADD,A_SUB,A_ADC,A_SBC,A_EOR,A_AND,A_OR,
  700. A_OUT,A_IN]) or
  701. { the reference register of ST/STD cannot be replaced }
  702. (MatchInstruction(hp1,[A_STD,A_ST]) and (MatchOperand(taicpu(p).oper[0]^,taicpu(hp1).oper[1]^)))) and
  703. (not RegModifiedByInstruction(taicpu(p).oper[0]^.reg, hp1)) and
  704. {(taicpu(hp1).ops=1) and
  705. (taicpu(hp1).oper[0]^.typ = top_reg) and
  706. (taicpu(hp1).oper[0]^.reg=taicpu(p).oper[0]^.reg) and }
  707. assigned(FindRegDeAlloc(taicpu(p).oper[0]^.reg,tai(hp1.Next))) then
  708. begin
  709. DebugMsg('Peephole MovOp2Op performed', p);
  710. for i := 0 to taicpu(hp1).ops-1 do
  711. if taicpu(hp1).oper[i]^.typ=top_reg then
  712. if taicpu(hp1).oper[i]^.reg=taicpu(p).oper[0]^.reg then
  713. taicpu(hp1).oper[i]^.reg:=taicpu(p).oper[1]^.reg;
  714. alloc:=FindRegAllocBackward(taicpu(p).oper[0]^.reg,tai(p.Previous));
  715. dealloc:=FindRegDeAlloc(taicpu(p).oper[0]^.reg,tai(hp1.Next));
  716. if assigned(alloc) and assigned(dealloc) then
  717. begin
  718. asml.Remove(alloc);
  719. alloc.Free;
  720. asml.Remove(dealloc);
  721. dealloc.Free;
  722. end;
  723. { life range of reg1 is increased }
  724. AllocRegBetween(taicpu(p).oper[1]^.reg,p,hp1,usedregs);
  725. { p will be removed, update used register as we continue
  726. with the next instruction after p }
  727. result:=RemoveCurrentP(p);
  728. end
  729. { remove
  730. mov reg0,reg0
  731. }
  732. else if (taicpu(p).ops=2) and
  733. (taicpu(p).oper[0]^.typ = top_reg) and
  734. (taicpu(p).oper[1]^.typ = top_reg) and
  735. (taicpu(p).oper[0]^.reg = taicpu(p).oper[1]^.reg) then
  736. begin
  737. DebugMsg('Peephole RedundantMov performed', p);
  738. result:=RemoveCurrentP(p);
  739. end
  740. {
  741. Turn
  742. mov rx,ry
  743. op rx,rz
  744. mov ry, rx
  745. Into
  746. op ry,rz
  747. }
  748. else if (taicpu(p).ops=2) and
  749. MatchOpType(taicpu(p),top_reg,top_reg) and
  750. GetNextInstructionUsingReg(p,hp1,taicpu(p).oper[0]^.reg) and
  751. (hp1.typ=ait_instruction) and
  752. (taicpu(hp1).ops >= 1) and
  753. (taicpu(hp1).oper[0]^.typ = top_reg) and
  754. GetNextInstructionUsingReg(hp1,hp2,taicpu(hp1).oper[0]^.reg) and
  755. MatchInstruction(hp2,A_MOV) and
  756. MatchOpType(taicpu(hp2),top_reg,top_reg) and
  757. (taicpu(hp2).oper[0]^.reg = taicpu(p).oper[1]^.reg) and
  758. (taicpu(hp2).oper[1]^.reg = taicpu(hp1).oper[0]^.reg) and
  759. (taicpu(hp2).oper[1]^.reg = taicpu(p).oper[0]^.reg) and
  760. (not RegModifiedBetween(taicpu(p).oper[1]^.reg,p,hp2)) and
  761. (taicpu(hp1).opcode in [A_ADD,A_ADC,A_SUB,A_SBC,A_AND,A_OR,A_EOR,
  762. A_INC,A_DEC,
  763. A_LSL,A_LSR,A_ASR,A_ROR,A_ROL]) and
  764. assigned(FindRegDeAlloc(taicpu(p).oper[0]^.reg, tai(hp2.Next))) then
  765. begin
  766. DebugMsg('Peephole MovOpMov2Op performed', p);
  767. if (taicpu(hp1).ops=2) and
  768. (taicpu(hp1).oper[1]^.typ=top_reg) and
  769. (taicpu(hp1).oper[1]^.reg = taicpu(p).oper[1]^.reg) then
  770. taicpu(hp1).oper[1]^.reg:=taicpu(p).oper[1]^.reg;
  771. taicpu(hp1).oper[0]^.reg:=taicpu(p).oper[1]^.reg;
  772. alloc:=FindRegAllocBackward(taicpu(p).oper[0]^.reg,tai(p.Previous));
  773. dealloc:=FindRegDeAlloc(taicpu(p).oper[0]^.reg,tai(hp2.Next));
  774. if assigned(alloc) and assigned(dealloc) then
  775. begin
  776. asml.Remove(alloc);
  777. alloc.Free;
  778. asml.Remove(dealloc);
  779. dealloc.Free;
  780. end;
  781. asml.remove(hp2);
  782. hp2.free;
  783. result:=RemoveCurrentP(p);
  784. end
  785. {
  786. Turn
  787. mov rx,ry
  788. op rx,rw
  789. mov rw,rx
  790. Into
  791. op rw,ry
  792. }
  793. else if (taicpu(p).ops=2) and
  794. MatchOpType(taicpu(p),top_reg,top_reg) and
  795. GetNextInstructionUsingReg(p,hp1,taicpu(p).oper[0]^.reg) and
  796. (hp1.typ=ait_instruction) and
  797. (taicpu(hp1).ops = 2) and
  798. MatchOpType(taicpu(hp1),top_reg,top_reg) and
  799. GetNextInstructionUsingReg(hp1,hp2,taicpu(hp1).oper[0]^.reg) and
  800. (hp2.typ=ait_instruction) and
  801. (taicpu(hp2).opcode=A_MOV) and
  802. MatchOpType(taicpu(hp2),top_reg,top_reg) and
  803. (taicpu(hp2).oper[0]^.reg = taicpu(hp1).oper[1]^.reg) and
  804. (taicpu(hp2).oper[1]^.reg = taicpu(hp1).oper[0]^.reg) and
  805. (taicpu(hp2).oper[1]^.reg = taicpu(p).oper[0]^.reg) and
  806. (not RegModifiedBetween(taicpu(p).oper[1]^.reg,p,hp1)) and
  807. (taicpu(hp1).opcode in [A_ADD,A_ADC,A_AND,A_OR,A_EOR]) and
  808. assigned(FindRegDeAlloc(taicpu(p).oper[0]^.reg, tai(hp2.Next))) then
  809. begin
  810. DebugMsg('Peephole MovOpMov2Op2 performed', p);
  811. taicpu(hp1).oper[0]^.reg:=taicpu(hp2).oper[0]^.reg;
  812. taicpu(hp1).oper[1]^.reg:=taicpu(p).oper[1]^.reg;
  813. alloc:=FindRegAllocBackward(taicpu(p).oper[0]^.reg,tai(p.Previous));
  814. dealloc:=FindRegDeAlloc(taicpu(p).oper[0]^.reg,tai(hp2.Next));
  815. if assigned(alloc) and assigned(dealloc) then
  816. begin
  817. asml.Remove(alloc);
  818. alloc.Free;
  819. asml.Remove(dealloc);
  820. dealloc.Free;
  821. end;
  822. result:=RemoveCurrentP(p);
  823. asml.remove(hp2);
  824. hp2.free;
  825. end
  826. { fold
  827. mov reg2,reg0
  828. mov reg3,reg1
  829. to
  830. movw reg2,reg0
  831. }
  832. else if (CPUAVR_HAS_MOVW in cpu_capabilities[current_settings.cputype]) and
  833. (taicpu(p).ops=2) and
  834. (taicpu(p).oper[0]^.typ = top_reg) and
  835. (taicpu(p).oper[1]^.typ = top_reg) and
  836. getnextinstruction(p,hp1) and
  837. (hp1.typ = ait_instruction) and
  838. (taicpu(hp1).opcode = A_MOV) and
  839. (taicpu(hp1).ops=2) and
  840. (taicpu(hp1).oper[0]^.typ = top_reg) and
  841. (taicpu(hp1).oper[1]^.typ = top_reg) and
  842. (getsupreg(taicpu(hp1).oper[0]^.reg)=getsupreg(taicpu(p).oper[0]^.reg)+1) and
  843. ((getsupreg(taicpu(p).oper[0]^.reg) mod 2)=0) and
  844. ((getsupreg(taicpu(p).oper[1]^.reg) mod 2)=0) and
  845. (getsupreg(taicpu(hp1).oper[1]^.reg)=getsupreg(taicpu(p).oper[1]^.reg)+1) then
  846. begin
  847. DebugMsg('Peephole MovMov2Movw performed', p);
  848. alloc:=FindRegAllocBackward(taicpu(hp1).oper[0]^.reg,tai(hp1.Previous));
  849. if assigned(alloc) then
  850. begin
  851. asml.Remove(alloc);
  852. asml.InsertBefore(alloc,p);
  853. { proper book keeping of currently used registers }
  854. IncludeRegInUsedRegs(taicpu(hp1).oper[0]^.reg,UsedRegs);
  855. end;
  856. taicpu(p).opcode:=A_MOVW;
  857. asml.remove(hp1);
  858. hp1.free;
  859. result:=true;
  860. end
  861. {
  862. This removes the first mov from
  863. mov rX,...
  864. mov rX,...
  865. }
  866. else if GetNextInstruction(p,hp1) and MatchInstruction(hp1,A_MOV) then
  867. while MatchInstruction(hp1,A_MOV) and
  868. MatchOperand(taicpu(p).oper[0]^, taicpu(hp1).oper[0]^) and
  869. { don't remove the first mov if the second is a mov rX,rX }
  870. not(MatchOperand(taicpu(hp1).oper[0]^,taicpu(hp1).oper[1]^)) do
  871. begin
  872. DebugMsg('Peephole MovMov2Mov performed', p);
  873. result:=RemoveCurrentP(p);
  874. GetNextInstruction(hp1,hp1);
  875. if not assigned(hp1) then
  876. break;
  877. end;
  878. end;
  879. A_SBIC,
  880. A_SBIS:
  881. begin
  882. {
  883. Turn
  884. sbic/sbis X, y
  885. jmp .L1
  886. op
  887. .L1:
  888. into
  889. sbis/sbic X,y
  890. op
  891. .L1:
  892. }
  893. if GetNextInstruction(p, hp1) and
  894. (hp1.typ=ait_instruction) and
  895. (taicpu(hp1).opcode in [A_JMP,A_RJMP]) and
  896. (taicpu(hp1).ops>0) and
  897. (taicpu(hp1).oper[0]^.typ = top_ref) and
  898. (taicpu(hp1).oper[0]^.ref^.symbol is TAsmLabel) and
  899. GetNextInstruction(hp1, hp2) and
  900. (hp2.typ=ait_instruction) and
  901. (not taicpu(hp2).is_jmp) and
  902. GetNextInstruction(hp2, hp3) and
  903. (hp3.typ=ait_label) and
  904. (taicpu(hp1).oper[0]^.ref^.symbol=tai_label(hp3).labsym) then
  905. begin
  906. DebugMsg('Peephole SbiJmp2Sbi performed',p);
  907. if taicpu(p).opcode=A_SBIC then
  908. taicpu(p).opcode:=A_SBIS
  909. else
  910. taicpu(p).opcode:=A_SBIC;
  911. tai_label(hp3).labsym.decrefs;
  912. AsmL.remove(hp1);
  913. taicpu(hp1).Free;
  914. result:=true;
  915. end
  916. {
  917. Turn
  918. sbiX X, y
  919. jmp .L1
  920. jmp .L2
  921. .L1:
  922. op
  923. .L2:
  924. into
  925. sbiX X,y
  926. .L1:
  927. op
  928. .L2:
  929. }
  930. else if GetNextInstruction(p, hp1) and
  931. (hp1.typ=ait_instruction) and
  932. (taicpu(hp1).opcode in [A_JMP,A_RJMP]) and
  933. (taicpu(hp1).ops>0) and
  934. (taicpu(hp1).oper[0]^.typ = top_ref) and
  935. (taicpu(hp1).oper[0]^.ref^.symbol is TAsmLabel) and
  936. GetNextInstruction(hp1, hp2) and
  937. (hp2.typ=ait_instruction) and
  938. (taicpu(hp2).opcode in [A_JMP,A_RJMP]) and
  939. (taicpu(hp2).ops>0) and
  940. (taicpu(hp2).oper[0]^.typ = top_ref) and
  941. (taicpu(hp2).oper[0]^.ref^.symbol is TAsmLabel) and
  942. GetNextInstruction(hp2, hp3) and
  943. (hp3.typ=ait_label) and
  944. (taicpu(hp1).oper[0]^.ref^.symbol=tai_label(hp3).labsym) and
  945. GetNextInstruction(hp3, hp4) and
  946. (hp4.typ=ait_instruction) and
  947. GetNextInstruction(hp4, hp5) and
  948. (hp3.typ=ait_label) and
  949. (taicpu(hp2).oper[0]^.ref^.symbol=tai_label(hp5).labsym) then
  950. begin
  951. DebugMsg('Peephole SbiJmpJmp2Sbi performed',p);
  952. tai_label(hp3).labsym.decrefs;
  953. tai_label(hp5).labsym.decrefs;
  954. AsmL.remove(hp1);
  955. taicpu(hp1).Free;
  956. AsmL.remove(hp2);
  957. taicpu(hp2).Free;
  958. result:=true;
  959. end;
  960. end;
  961. end;
  962. end;
  963. end;
  964. end;
  965. procedure TCpuAsmOptimizer.PeepHoleOptPass2;
  966. begin
  967. end;
  968. begin
  969. casmoptimizer:=TCpuAsmOptimizer;
  970. End.