From f1b8fad6dc99ba99fcd5a52e35d2b613a965d3f1 Mon Sep 17 00:00:00 2001 From: florian Date: Sun, 20 Jan 2013 14:57:59 +0000 Subject: [PATCH] * make AndAnd2And working with other instructions in between git-svn-id: trunk@23461 - --- compiler/arm/aoptcpu.pas | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/compiler/arm/aoptcpu.pas b/compiler/arm/aoptcpu.pas index d9a6f99070..e093247248 100644 --- a/compiler/arm/aoptcpu.pas +++ b/compiler/arm/aoptcpu.pas @@ -1187,24 +1187,38 @@ Implementation { change and reg2,reg1,const1 + ... and reg3,reg2,const2 to and reg3,reg1,(const1 and const2) } - if GetNextInstruction(p, hp1) and + if GetNextInstructionUsingReg(p,hp1,taicpu(p).oper[0]^.reg) and MatchInstruction(hp1, A_AND, [taicpu(p).condition], [PF_None]) and - { either reg3 and reg2 are equal or reg2 is deallocated after the and } - (MatchOperand(taicpu(hp1).oper[0]^, taicpu(p).oper[0]^.reg) or - assigned(FindRegDealloc(taicpu(p).oper[0]^.reg,tai(hp1.Next)))) and + RegEndOfLife(taicpu(p).oper[0]^.reg,taicpu(hp1)) and MatchOperand(taicpu(hp1).oper[1]^, taicpu(p).oper[0]^.reg) and (taicpu(hp1).oper[2]^.typ = top_const) then begin - DebugMsg('Peephole AndAnd2And done', p); - taicpu(p).loadConst(2,taicpu(p).oper[2]^.val and taicpu(hp1).oper[2]^.val); - taicpu(p).oppostfix:=taicpu(hp1).oppostfix; - taicpu(p).loadReg(0,taicpu(hp1).oper[0]^.reg); - asml.remove(hp1); - hp1.free; + if not(RegUsedBetween(taicpu(hp1).oper[0]^.reg,p,hp1)) then + begin + DebugMsg('Peephole AndAnd2And 1 done', p); + taicpu(p).loadConst(2,taicpu(p).oper[2]^.val and taicpu(hp1).oper[2]^.val); + taicpu(p).oppostfix:=taicpu(hp1).oppostfix; + taicpu(p).loadReg(0,taicpu(hp1).oper[0]^.reg); + asml.remove(hp1); + hp1.free; + Result:=true; + end + else if not(RegUsedBetween(taicpu(p).oper[1]^.reg,p,hp1)) then + begin + DebugMsg('Peephole AndAnd2And 2 done', hp1); + taicpu(hp1).loadConst(2,taicpu(hp1).oper[2]^.val and taicpu(hp1).oper[2]^.val); + taicpu(hp1).oppostfix:=taicpu(p).oppostfix; + taicpu(hp1).loadReg(1,taicpu(p).oper[1]^.reg); + asml.remove(p); + p.free; + p:=hp1; + Result:=true; + end; end { change