* do for-loop unrolling after for-loop simplification, resolves #36589

git-svn-id: trunk@43999 -
This commit is contained in:
florian 2020-01-19 18:21:12 +00:00
parent 2b658ef11c
commit 069e040e49
3 changed files with 26 additions and 17 deletions

1
.gitattributes vendored
View File

@ -17956,6 +17956,7 @@ tests/webtbs/tw3650.pp svneol=native#text/plain
tests/webtbs/tw3653.pp svneol=native#text/plain
tests/webtbs/tw36544a.pp svneol=native#text/pascal
tests/webtbs/tw36544b.pp svneol=native#text/pascal
tests/webtbs/tw36589.pp svneol=native#text/pascal
tests/webtbs/tw3661.pp svneol=native#text/plain
tests/webtbs/tw3666.pp svneol=native#text/plain
tests/webtbs/tw3669.pp svneol=native#text/plain

View File

@ -1690,8 +1690,26 @@ implementation
set_varstate(left,vs_written,[]);
{ Make sure that the loop var and the
from and to values are compatible types }
if not(m_iso in current_settings.modeswitches) then
rangedef:=left.resultdef
else
rangedef:=get_iso_range_type(left.resultdef);
check_ranges(right.fileinfo,right,rangedef);
inserttypeconv(right,rangedef);
check_ranges(t1.fileinfo,t1,rangedef);
inserttypeconv(t1,rangedef);
if assigned(t2) then
typecheckpass(t2);
result:=simplify(false);
{ loop unrolling }
if (cs_opt_loopunroll in current_settings.optimizerswitches) and
if not(assigned(result)) and
(cs_opt_loopunroll in current_settings.optimizerswitches) and
assigned(t2) and
{ statements must be error free }
not(nf_error in t2.flags) then
@ -1709,22 +1727,6 @@ implementation
end;
end;
{ Make sure that the loop var and the
from and to values are compatible types }
if not(m_iso in current_settings.modeswitches) then
rangedef:=left.resultdef
else
rangedef:=get_iso_range_type(left.resultdef);
check_ranges(right.fileinfo,right,rangedef);
inserttypeconv(right,rangedef);
check_ranges(t1.fileinfo,t1,rangedef);
inserttypeconv(t1,rangedef);
if assigned(t2) then
typecheckpass(t2);
result:=simplify(false);
end;

6
tests/webtbs/tw36589.pp Normal file
View File

@ -0,0 +1,6 @@
var k : longint;
begin
for k:=1 downto 10 do
begin
end;
end.