* setup proper starting value when optimizing away a loop, resolves #9096

git-svn-id: trunk@8443 -
This commit is contained in:
florian 2007-09-12 19:41:36 +00:00
parent d304408a1b
commit 1b7aeb568c
3 changed files with 23 additions and 3 deletions

1
.gitattributes vendored
View File

@ -8392,6 +8392,7 @@ tests/webtbs/tw9073.pp svneol=native#text/plain
tests/webtbs/tw9076.pp svneol=native#text/plain
tests/webtbs/tw9076a.pp svneol=native#text/plain
tests/webtbs/tw9085.pp svneol=native#text/plain
tests/webtbs/tw9096.pp svneol=native#text/plain
tests/webtbs/tw9098.pp svneol=native#text/plain
tests/webtbs/tw9107.pp svneol=native#text/plain
tests/webtbs/tw9108.pp svneol=native#text/plain

View File

@ -36,7 +36,7 @@ unit optunrol;
globtype,globals,constexp,
cpuinfo,
nutils,
nbas,nflw,ncon,ninl,ncal;
nbas,nflw,ncon,ninl,ncal,nld;
var
nodecount : aword;
@ -76,7 +76,7 @@ unit optunrol;
var
unrolls,i : cardinal;
counts : qword;
unrollstatement : tstatementnode;
unrollstatement,newforstatement : tstatementnode;
unrollblock : tblocknode;
begin
result:=nil;
@ -126,7 +126,14 @@ unit optunrol;
end;
{ can we get rid of the for statement? }
if unrolls=counts then
result:=unrollblock;
begin
{ create block statement }
result:=internalstatements(newforstatement);
{ initial assignment }
addstatement(newforstatement,cassignmentnode.create(
tfornode(node).left.getcopy,tfornode(node).right.getcopy));
addstatement(newforstatement,unrollblock);
end;
end
else
begin

12
tests/webtbs/tw9096.pp Normal file
View File

@ -0,0 +1,12 @@
{ %OPT=-Ooloopunroll }
var
arr : array[0..0,0..0] of longint;
i : longint;
begin
i:=1234;
for i := 0 to 0 do
if i<>0 then
halt(1);
writeln('ok');
end.