mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-18 15:29:11 +02:00
* handle unrolling of for ... downto ... correctly, resolves #15668
git-svn-id: trunk@14884 -
This commit is contained in:
parent
e89d0bcee3
commit
092153e7ad
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -10278,6 +10278,7 @@ tests/webtbs/tw15504.pp svneol=native#text/plain
|
|||||||
tests/webtbs/tw15530.pp svneol=native#text/pascal
|
tests/webtbs/tw15530.pp svneol=native#text/pascal
|
||||||
tests/webtbs/tw15607.pp svneol=native#text/plain
|
tests/webtbs/tw15607.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw15619.pp svneol=native#text/plain
|
tests/webtbs/tw15619.pp svneol=native#text/plain
|
||||||
|
tests/webtbs/tw15668.pp svneol=native#text/pascal
|
||||||
tests/webtbs/tw1567.pp svneol=native#text/plain
|
tests/webtbs/tw1567.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw15690.pp svneol=native#text/plain
|
tests/webtbs/tw15690.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw15693.pp svneol=native#text/plain
|
tests/webtbs/tw15693.pp svneol=native#text/plain
|
||||||
|
@ -127,9 +127,13 @@ unit optloop;
|
|||||||
{ for itself increases at the last iteration }
|
{ for itself increases at the last iteration }
|
||||||
if i<unrolls then
|
if i<unrolls then
|
||||||
begin
|
begin
|
||||||
{ insert incrementation of counter var }
|
{ insert incr/decrementation of counter var }
|
||||||
addstatement(unrollstatement,
|
if lnf_backward in tfornode(node).loopflags then
|
||||||
geninlinenode(in_inc_x,false,ccallparanode.create(tfornode(node).left.getcopy,nil)));
|
addstatement(unrollstatement,
|
||||||
|
geninlinenode(in_dec_x,false,ccallparanode.create(tfornode(node).left.getcopy,nil)))
|
||||||
|
else
|
||||||
|
addstatement(unrollstatement,
|
||||||
|
geninlinenode(in_inc_x,false,ccallparanode.create(tfornode(node).left.getcopy,nil)));
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
{ can we get rid of the for statement? }
|
{ can we get rid of the for statement? }
|
||||||
|
16
tests/webtbs/tw15668.pp
Normal file
16
tests/webtbs/tw15668.pp
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
{ %OPT=-Ooloopunroll -O2 -S2 -Cr }
|
||||||
|
const
|
||||||
|
StrArray :array[0..1] of string = ('s1','s2');
|
||||||
|
|
||||||
|
function FindStr(const s :string) :Integer;
|
||||||
|
var
|
||||||
|
i :Integer;
|
||||||
|
begin
|
||||||
|
for i := High(StrArray) downto 0 do
|
||||||
|
if StrArray[i] = s then Exit(i);
|
||||||
|
Result := -1;
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
FindStr('s1');
|
||||||
|
end.
|
Loading…
Reference in New Issue
Block a user