* more robust code for constant propagation in for loops

This commit is contained in:
florian 2022-05-21 22:31:51 +02:00
parent f1cb5d8f71
commit 91481a5fae

View File

@ -132,9 +132,11 @@ unit optconstprop;
begin
result:=replaceBasicAssign(tfornode(n).right, arg, tree_modified);
if result then
replaceBasicAssign(tfornode(n).t1, arg, tree_modified2);
begin
{ play safe and set the result which is check below }
result:=replaceBasicAssign(tfornode(n).t1, arg, tree_modified2);
tree_modified:=tree_modified or tree_modified2;
if pi_dfaavailable in current_procinfo.flags then
if result and (pi_dfaavailable in current_procinfo.flags) then
begin
CalcDefSum(tfornode(n).t2);
{ the constant can propagete if is is not the counter variable ... }
@ -146,11 +148,15 @@ unit optconstprop;
begin
replaceBasicAssign(tfornode(n).t2, arg, tree_modified3);
tree_modified:=tree_modified or tree_modified3;
end;
end;
{ after a for node we cannot continue with our simple approach }
result:=false;
end
else
result:=false;
end
else
result:=false;
end;
end
else if n.nodetype=blockn then
begin
changed:=false;