* Fixed arm optimizer bug (mantis #9209). No testsuite regressions with -O2.

* Removed unused local vars.
+ test.

git-svn-id: trunk@7970 -
This commit is contained in:
yury 2007-07-06 13:09:28 +00:00
parent 6096874424
commit 2829f4e46f
3 changed files with 35 additions and 4 deletions

1
.gitattributes vendored
View File

@ -8324,6 +8324,7 @@ tests/webtbs/tw9174.pp svneol=native#text/plain
tests/webtbs/tw9179.pp svneol=native#text/plain
tests/webtbs/tw9187.pp svneol=native#text/plain
tests/webtbs/tw9190.pp svneol=native#text/plain
tests/webtbs/tw9209.pp svneol=native#text/plain
tests/webtbs/ub1873.pp svneol=native#text/plain
tests/webtbs/ub1883.pp svneol=native#text/plain
tests/webtbs/uw0555.pp svneol=native#text/plain

View File

@ -50,8 +50,7 @@ Implementation
function TCpuAsmOptimizer.PeepHoleOptPass1Cpu(var p: tai): boolean;
var
next1, next2: tai;
l1, l2, shlcount: longint;
next1: tai;
begin
result := false;
case p.typ of
@ -110,6 +109,7 @@ Implementation
l : longint;
condition : tasmcond;
hp3: tai;
WasLast: boolean;
{ UsedRegs, TmpUsedRegs: TRegSet; }
begin
@ -131,6 +131,7 @@ Implementation
xxx:
}
l:=0;
WasLast:=False;
GetNextInstruction(p, hp1);
while assigned(hp1) and
(l<=4) and
@ -141,6 +142,7 @@ Implementation
inc(l);
if MustBeLast(hp1) then
begin
WasLast:=True;
GetNextInstruction(hp1,hp1);
break;
end
@ -180,13 +182,17 @@ Implementation
end;
end
else
{ do not perform further optimizations if there is inctructon
in block #1 which can not be optimized.
}
if not WasLast then
begin
{ check further for
Bcc xxx
<several movs 1>
<several instructions 1>
B yyy
xxx:
<several movs 2>
<several instructions 2>
yyy:
}
{ hp2 points to jmp yyy }

24
tests/webtbs/tw9209.pp Normal file
View File

@ -0,0 +1,24 @@
{%OPT=-O2}
procedure Proc1(i: integer);
begin
if i = 1 then
Inc(i);
end;
procedure Proc2;
begin
writeln('Test failed!');
Halt(1);
end;
var
i, j: integer;
begin
if (i = 0) and (j = 0) then
Proc1(i)
else
Proc2;
writeln('Test OK.');
end.