mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-25 03:29:14 +02:00
* more robust code for constant propagation in for loops
This commit is contained in:
parent
f1cb5d8f71
commit
91481a5fae
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user