* replace lea by add if possible

git-svn-id: trunk@25907 -
This commit is contained in:
florian 2013-11-01 19:01:33 +00:00
parent 80f8f66c6e
commit a16ceb6cdf

View File

@ -1033,19 +1033,20 @@ begin
(getsupreg(taicpu(p).oper[0]^.ref^.base) in [RS_EAX..RS_ESP]) and (getsupreg(taicpu(p).oper[0]^.ref^.base) in [RS_EAX..RS_ESP]) and
(taicpu(p).oper[0]^.ref^.index = NR_NO) and (taicpu(p).oper[0]^.ref^.index = NR_NO) and
(not(Assigned(taicpu(p).oper[0]^.ref^.Symbol))) then (not(Assigned(taicpu(p).oper[0]^.ref^.Symbol))) then
if (taicpu(p).oper[0]^.ref^.base <> taicpu(p).oper[1]^.reg) and begin
(taicpu(p).oper[0]^.ref^.offset = 0) then if (taicpu(p).oper[0]^.ref^.base <> taicpu(p).oper[1]^.reg) and
begin (taicpu(p).oper[0]^.ref^.offset = 0) then
hp1 := taicpu.op_reg_reg(A_MOV, S_L,taicpu(p).oper[0]^.ref^.base, begin
taicpu(p).oper[1]^.reg); hp1 := taicpu.op_reg_reg(A_MOV, S_L,taicpu(p).oper[0]^.ref^.base,
InsertLLItem(asml,p.previous,p.next, hp1); taicpu(p).oper[1]^.reg);
p.free; InsertLLItem(asml,p.previous,p.next, hp1);
p := hp1; p.free;
continue; p := hp1;
end continue;
else if (taicpu(p).oper[0]^.ref^.offset = 0) then end
begin else if (taicpu(p).oper[0]^.ref^.offset = 0) then
hp1 := tai(p.Next); begin
hp1 := tai(p.Next);
asml.remove(p); asml.remove(p);
p.free; p.free;
p := hp1; p := hp1;
@ -1076,15 +1077,36 @@ begin
if (l<0) and (l<>-2147483648) then if (l<0) and (l<>-2147483648) then
begin begin
taicpu(p).opcode := A_SUB; taicpu(p).opcode := A_SUB;
taicpu(p).loadConst(0,-l); taicpu(p).loadConst(0,-l);
end end
else else
begin begin
taicpu(p).opcode := A_ADD; taicpu(p).opcode := A_ADD;
taicpu(p).loadConst(0,l); taicpu(p).loadConst(0,l);
end; end;
end; end;
end; end;
end
else if MatchReference(taicpu(p).oper[0]^.ref^,taicpu(p).oper[1]^.reg,NR_INVALID) then
begin
hp1:=taicpu.op_reg_reg(A_ADD,S_L,taicpu(p).oper[0]^.ref^.index,
taicpu(p).oper[0]^.ref^.base);
InsertLLItem(asml,p.previous,p.next, hp1);
DebugMsg('Peephole Lea2AddBase done',hp1);
p.free;
p:=hp1;
continue;
end
else if MatchReference(taicpu(p).oper[0]^.ref^,NR_INVALID,taicpu(p).oper[1]^.reg) then
begin
hp1:=taicpu.op_reg_reg(A_ADD,S_L,taicpu(p).oper[0]^.ref^.base,
taicpu(p).oper[0]^.ref^.index);
InsertLLItem(asml,p.previous,p.next,hp1);
DebugMsg('Peephole Lea2AddIndex done',hp1);
p.free;
p:=hp1;
continue;
end
end; end;
A_MOV: A_MOV:
begin begin