From f813703cf350b9924d3542dfb86d86ca6dc1393d Mon Sep 17 00:00:00 2001 From: florian Date: Wed, 31 Dec 2014 15:45:06 +0000 Subject: [PATCH] * fixes several issues with loop unrolling git-svn-id: trunk@29362 - --- compiler/nflw.pas | 5 ++++- compiler/optloop.pas | 11 ++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/compiler/nflw.pas b/compiler/nflw.pas index b95d71e6f4..bc6edd8c18 100644 --- a/compiler/nflw.pas +++ b/compiler/nflw.pas @@ -1524,8 +1524,11 @@ implementation set_varstate(left,vs_written,[]); { 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 + typecheckpass(t2); res:=t2.simplify(false); if assigned(res) then t2:=res; diff --git a/compiler/optloop.pas b/compiler/optloop.pas index 9a8ea5acaf..2f312aed24 100644 --- a/compiler/optloop.pas +++ b/compiler/optloop.pas @@ -81,10 +81,7 @@ unit optloop; function replaceloadnodes(var n: tnode; arg: pointer): foreachnoderesult; begin - if ((n.nodetype=loadn) and (preplaceinfo(arg)^.node.nodetype=loadn) and - (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 + if n.isequal(preplaceinfo(arg)^.node) then begin if n.flags*[nf_modify,nf_write,nf_address_taken]<>[] then internalerror(2012090402); @@ -135,12 +132,12 @@ unit optloop; unrollblock:=internalstatements(unrollstatement); { 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 begin - if not(tfornode(node).left.nodetype in [temprefn,loadn]) then - internalerror(2012090301); replaceinfo.node:=tfornode(node).left; replaceinfo.value:=tordconstnode(tfornode(node).right).value; end;