* fix several issues with loop strength reduction to make it working

* debugging code for strength reduction

git-svn-id: trunk@26694 -
This commit is contained in:
florian 2014-02-06 20:48:19 +00:00
parent c41d043ac8
commit 30352c7f7b

View File

@ -23,6 +23,8 @@ unit optloop;
{$i fpcdefs.inc}
{ $define DEBUG_OPTSTRENGTH}
interface
uses
@ -388,7 +390,7 @@ unit optloop;
{ direct array access? }
((tvecnode(n).left.nodetype=loadn) or
{ ... or loop invariant expression? }
is_loop_invariant(tfornode(arg),tvecnode(n).left)) and
is_loop_invariant(tfornode(arg),tvecnode(n).right)) and
{ removing the multiplication is only worth the
effort if it's not a simple shift }
not(ispowerof2(tcgvecnode(n).get_mul_size,dummy)) then
@ -397,6 +399,12 @@ unit optloop;
{ did we use the same expression before already? }
if not(findpreviousstrengthreduction) then
begin
{$ifdef DEBUG_OPTSTRENGTH}
writeln('**********************************************************************************');
writeln('Found expression for strength reduction: ');
printnode(n);
writeln('**********************************************************************************');
{$endif DEBUG_OPTSTRENGTH}
tempnode:=ctempcreatenode.create(voidpointertype,voidpointertype.size,tt_persistent,true);
templist.Add(tempnode);
@ -476,10 +484,10 @@ unit optloop;
node:=fornode;
loopcode:=internalstatements(loopcodestatements);
addstatement(loopcodestatements,calccode);
addstatement(loopcodestatements,tfornode(node).t2);
tfornode(node).t2:=loopcode;
do_firstpass(node);
addstatement(loopcodestatements,calccode);
result:=internalstatements(newcodestatements);
addstatement(newcodestatements,initcode);
@ -501,7 +509,7 @@ unit optloop;
{ do we have DFA available? }
if pi_dfaavailable in current_procinfo.flags then
begin
CalcDefSum(n);
CalcDefSum(tfornode(n).t2);
end;
containsnestedforloop:=false;
@ -526,3 +534,4 @@ unit optloop;
end;
end.