mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-12-05 12:27:20 +01:00
* fixes several issues with loop unrolling
git-svn-id: trunk@29362 -
This commit is contained in:
parent
868ba1560f
commit
f813703cf3
@ -1524,8 +1524,11 @@ implementation
|
|||||||
set_varstate(left,vs_written,[]);
|
set_varstate(left,vs_written,[]);
|
||||||
|
|
||||||
{ loop unrolling }
|
{ loop unrolling }
|
||||||
if cs_opt_loopunroll in current_settings.optimizerswitches then
|
if (cs_opt_loopunroll in current_settings.optimizerswitches) and
|
||||||
|
{ statements must be error free }
|
||||||
|
not(nf_error in t2.flags) then
|
||||||
begin
|
begin
|
||||||
|
typecheckpass(t2);
|
||||||
res:=t2.simplify(false);
|
res:=t2.simplify(false);
|
||||||
if assigned(res) then
|
if assigned(res) then
|
||||||
t2:=res;
|
t2:=res;
|
||||||
|
|||||||
@ -81,10 +81,7 @@ unit optloop;
|
|||||||
|
|
||||||
function replaceloadnodes(var n: tnode; arg: pointer): foreachnoderesult;
|
function replaceloadnodes(var n: tnode; arg: pointer): foreachnoderesult;
|
||||||
begin
|
begin
|
||||||
if ((n.nodetype=loadn) and (preplaceinfo(arg)^.node.nodetype=loadn) and
|
if n.isequal(preplaceinfo(arg)^.node) then
|
||||||
(tloadnode(n).symtableentry=tloadnode(preplaceinfo(arg)^.node).symtableentry)) or
|
|
||||||
((n.nodetype=temprefn) and (preplaceinfo(arg)^.node.nodetype=temprefn) and
|
|
||||||
(ttemprefnode(n).tempinfo=ttemprefnode(preplaceinfo(arg)^.node).tempinfo)) then
|
|
||||||
begin
|
begin
|
||||||
if n.flags*[nf_modify,nf_write,nf_address_taken]<>[] then
|
if n.flags*[nf_modify,nf_write,nf_address_taken]<>[] then
|
||||||
internalerror(2012090402);
|
internalerror(2012090402);
|
||||||
@ -135,12 +132,12 @@ unit optloop;
|
|||||||
unrollblock:=internalstatements(unrollstatement);
|
unrollblock:=internalstatements(unrollstatement);
|
||||||
|
|
||||||
{ can we get rid completly of the for ? }
|
{ can we get rid completly of the for ? }
|
||||||
getridoffor:=(unrolls=counts) and not(usesbreakcontinue);
|
getridoffor:=(unrolls=counts) and not(usesbreakcontinue) and
|
||||||
|
{ TP/Macpas allows assignments to the for-variables, so we cannot get rid of the for }
|
||||||
|
([m_tp7,m_mac]*current_settings.modeswitches=[]);
|
||||||
|
|
||||||
if getridoffor then
|
if getridoffor then
|
||||||
begin
|
begin
|
||||||
if not(tfornode(node).left.nodetype in [temprefn,loadn]) then
|
|
||||||
internalerror(2012090301);
|
|
||||||
replaceinfo.node:=tfornode(node).left;
|
replaceinfo.node:=tfornode(node).left;
|
||||||
replaceinfo.value:=tordconstnode(tfornode(node).right).value;
|
replaceinfo.value:=tordconstnode(tfornode(node).right).value;
|
||||||
end;
|
end;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user