m68k: attempt to make MOVE+OP+MOVE optmization more robust. this fixes random exceptions in tfmtbcd test among others

git-svn-id: trunk@36480 -
This commit is contained in:
Károly Balogh 2017-06-10 21:54:48 +00:00
parent d3a47bc6b5
commit 40fb45aef6

View File

@ -135,6 +135,7 @@ unit aoptcpu;
var var
next, next2: tai; next, next2: tai;
opstr: string[15]; opstr: string[15];
TmpUsedRegs : TAllUsedRegs;
begin begin
result:=false; result:=false;
@ -145,8 +146,11 @@ unit aoptcpu;
(taicpu(p).oper[1]^.typ = top_reg) and (taicpu(p).oper[1]^.typ = top_reg) and
MatchOperand(taicpu(p).oper[1]^,taicpu(next).oper[0]^) then MatchOperand(taicpu(p).oper[1]^,taicpu(next).oper[0]^) then
begin begin
CopyUsedRegs(TmpUsedRegs);
UpdateUsedRegs(TmpUsedRegs, tai(next));
if not(RegInOp(taicpu(p).oper[1]^.reg,taicpu(next).oper[1]^)) and if not(RegInOp(taicpu(p).oper[1]^.reg,taicpu(next).oper[1]^)) and
RegEndOfLife(taicpu(next).oper[0]^.reg, taicpu(next)) then not(RegUsedAfterInstruction(taicpu(next).oper[0]^.reg,next,TmpUsedRegs)) then
begin begin
opstr:=opname(p); opstr:=opname(p);
case taicpu(p).oper[0]^.typ of case taicpu(p).oper[0]^.typ of
@ -195,6 +199,7 @@ unit aoptcpu;
end; end;
end; end;
end; end;
ReleaseUsedRegs(TmpUsedRegs);
exit; exit;
end; end;
@ -216,24 +221,30 @@ unit aoptcpu;
opstr:=opname(p); opstr:=opname(p);
if not(RegInOp(taicpu(p).oper[1]^.reg,taicpu(next2).oper[1]^)) and if not(RegInOp(taicpu(p).oper[1]^.reg,taicpu(next2).oper[1]^)) and
not(RegInOp(taicpu(p).oper[1]^.reg,taicpu(next).oper[0]^)) and not(RegInOp(taicpu(p).oper[1]^.reg,taicpu(next).oper[0]^)) then
RegEndOfLife(taicpu(p).oper[0]^.reg, taicpu(next2)) then
begin begin
{ move %reg0, %tmpreg CopyUsedRegs(TmpUsedRegs);
op ???, %tmpreg UpdateUsedRegs(TmpUsedRegs, tai(next));
move %tmpreg, %reg0 UpdateUsedRegs(TmpUsedRegs, tai(next2));
to: if not(RegUsedAfterInstruction(taicpu(p).oper[1]^.reg,next2,TmpUsedRegs)) then
op ???, %reg0 }
if MatchOperand(taicpu(p).oper[1]^,taicpu(next).oper[taicpu(next).ops-1]^) then
begin begin
DebugMsg('Optimizer: '+opstr+' + OP + '+opstr+' to OP #1',next); { move %reg0, %tmpreg
taicpu(next).loadOper(taicpu(next).ops-1,taicpu(p).oper[0]^); op ???, %tmpreg
asml.remove(p); move %tmpreg, %reg0
asml.remove(next2); to:
p.free; op ???, %reg0 }
next2.free; if MatchOperand(taicpu(p).oper[1]^,taicpu(next).oper[taicpu(next).ops-1]^) then
result:=true; begin
DebugMsg('Optimizer: '+opstr+' + OP + '+opstr+' to OP #1',next);
taicpu(next).loadOper(taicpu(next).ops-1,taicpu(p).oper[0]^);
asml.remove(p);
asml.remove(next2);
p.free;
next2.free;
result:=true;
end;
end; end;
ReleaseUsedRegs(TmpUsedRegs);
end; end;
end; end;
end; end;