* more fixes for loop strength reduction

git-svn-id: trunk@43912 -
This commit is contained in:
florian 2020-01-11 20:37:05 +00:00
parent a9a711763f
commit aabd7c7217
2 changed files with 11 additions and 4 deletions

View File

@ -266,7 +266,7 @@ unit optloop;
{ no aliasing? }
result:=not(tabstractvarsym(tloadnode(expr).symtableentry).addr_taken) and
{ no definition in the loop? }
not(DFASetIn(loop.optinfo^.defsum,expr.optinfo^.index));
not(DFASetIn(tfornode(loop).t2.optinfo^.defsum,expr.optinfo^.index));
end;
vecn:
begin
@ -375,8 +375,7 @@ unit optloop;
addstatement(initcodestatements,tempnode);
addstatement(initcodestatements,cassignmentnode.create(ctemprefnode.create(tempnode),
caddnode.create(muln,
caddnode.create(subn,tfornode(arg).right.getcopy,cordconstnode.create(1,tfornode(arg).right.resultdef,false)),
caddnode.create(muln,tfornode(arg).right.getcopy,
taddnode(n).right.getcopy)
)
);
@ -396,6 +395,7 @@ unit optloop;
begin
{ is the index the counter variable? }
if not(is_special_array(tvecnode(n).left.resultdef)) and
not(is_packed_array(tvecnode(n).left.resultdef)) and
(tvecnode(n).right.isequal(tfornode(arg).left) or
{ fpc usually creates a type cast to access an array }
((tvecnode(n).right.nodetype=typeconvn) and

View File

@ -348,7 +348,14 @@ unit optutils;
function adddef(var n: tnode; arg: pointer): foreachnoderesult;
begin
if assigned(n.optinfo) then
DFASetIncludeSet(defsum,n.optinfo^.def);
begin
DFASetIncludeSet(defsum,n.optinfo^.def);
{ for nodes itself do not necessarily expose the definition of the counter as
the counter might be undefined after the for loop, so include here the counter
explicitly }
if (n.nodetype=forn) and assigned(tfornode(n).left.optinfo) then
DFASetInclude(defsum,tfornode(n).left.optinfo^.index);
end;
Result:=fen_false;
end;