mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-13 23:59:10 +02:00
* 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:
parent
c41d043ac8
commit
30352c7f7b
@ -23,6 +23,8 @@ unit optloop;
|
|||||||
|
|
||||||
{$i fpcdefs.inc}
|
{$i fpcdefs.inc}
|
||||||
|
|
||||||
|
{ $define DEBUG_OPTSTRENGTH}
|
||||||
|
|
||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
@ -388,7 +390,7 @@ unit optloop;
|
|||||||
{ direct array access? }
|
{ direct array access? }
|
||||||
((tvecnode(n).left.nodetype=loadn) or
|
((tvecnode(n).left.nodetype=loadn) or
|
||||||
{ ... or loop invariant expression? }
|
{ ... 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
|
{ removing the multiplication is only worth the
|
||||||
effort if it's not a simple shift }
|
effort if it's not a simple shift }
|
||||||
not(ispowerof2(tcgvecnode(n).get_mul_size,dummy)) then
|
not(ispowerof2(tcgvecnode(n).get_mul_size,dummy)) then
|
||||||
@ -397,6 +399,12 @@ unit optloop;
|
|||||||
{ did we use the same expression before already? }
|
{ did we use the same expression before already? }
|
||||||
if not(findpreviousstrengthreduction) then
|
if not(findpreviousstrengthreduction) then
|
||||||
begin
|
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);
|
tempnode:=ctempcreatenode.create(voidpointertype,voidpointertype.size,tt_persistent,true);
|
||||||
|
|
||||||
templist.Add(tempnode);
|
templist.Add(tempnode);
|
||||||
@ -476,10 +484,10 @@ unit optloop;
|
|||||||
node:=fornode;
|
node:=fornode;
|
||||||
|
|
||||||
loopcode:=internalstatements(loopcodestatements);
|
loopcode:=internalstatements(loopcodestatements);
|
||||||
addstatement(loopcodestatements,calccode);
|
|
||||||
addstatement(loopcodestatements,tfornode(node).t2);
|
addstatement(loopcodestatements,tfornode(node).t2);
|
||||||
tfornode(node).t2:=loopcode;
|
tfornode(node).t2:=loopcode;
|
||||||
do_firstpass(node);
|
do_firstpass(node);
|
||||||
|
addstatement(loopcodestatements,calccode);
|
||||||
|
|
||||||
result:=internalstatements(newcodestatements);
|
result:=internalstatements(newcodestatements);
|
||||||
addstatement(newcodestatements,initcode);
|
addstatement(newcodestatements,initcode);
|
||||||
@ -501,7 +509,7 @@ unit optloop;
|
|||||||
{ do we have DFA available? }
|
{ do we have DFA available? }
|
||||||
if pi_dfaavailable in current_procinfo.flags then
|
if pi_dfaavailable in current_procinfo.flags then
|
||||||
begin
|
begin
|
||||||
CalcDefSum(n);
|
CalcDefSum(tfornode(n).t2);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
containsnestedforloop:=false;
|
containsnestedforloop:=false;
|
||||||
@ -526,3 +534,4 @@ unit optloop;
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user