From 84f0b62f93b2d2dd5a7a444ca0a0497056ff716a Mon Sep 17 00:00:00 2001 From: florian Date: Wed, 15 Nov 2006 21:59:29 +0000 Subject: [PATCH] * cond. instruction optimization enabled git-svn-id: trunk@5393 - --- compiler/arm/aoptcpu.pas | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/compiler/arm/aoptcpu.pas b/compiler/arm/aoptcpu.pas index 1b2984e19f..ec99bdf715 100644 --- a/compiler/arm/aoptcpu.pas +++ b/compiler/arm/aoptcpu.pas @@ -46,6 +46,16 @@ Implementation result:=true; end; + + { instructions modifying the CPSR can be only the last instruction } + function MustBeLast(p : tai) : boolean; + begin + Result:=(p.typ=ait_instruction) and + ((taicpu(p).opcode in [A_BL,A_BLX,A_CMP,A_CMN,A_SWI,A_TEQ,A_TST]) or + (taicpu(p).oppostfix=PF_S)); + end; + + procedure TCpuAsmOptimizer.PeepHoleOptPass2; var p,hp1,hp2: tai; @@ -55,7 +65,6 @@ Implementation { UsedRegs, TmpUsedRegs: TRegSet; } begin - exit; { deactived, not working yet FK } p := BlockStart; { UsedRegs := []; } while (p <> BlockEnd) Do @@ -82,7 +91,13 @@ Implementation not(hp1.typ=ait_label) do begin inc(l); - GetNextInstruction(hp1,hp1); + if MustBeLast(hp1) then + begin + GetNextInstruction(hp1,hp1); + break; + end + else + GetNextInstruction(hp1,hp1); end; if assigned(hp1) then begin @@ -97,7 +112,13 @@ Implementation repeat if hp1.typ=ait_instruction then taicpu(hp1).condition:=condition; - GetNextInstruction(hp1,hp1); + if MustBeLast(hp1) then + begin + GetNextInstruction(hp1,hp1); + break; + end + else + GetNextInstruction(hp1,hp1); until not(assigned(hp1)) or not(CanBeCond(hp1)) or (hp1.typ=ait_label);