* fixed concat_string optimization and enabled it when

-dnewoptimizations is used
This commit is contained in:
Jonas Maebe 2000-04-08 16:22:11 +00:00
parent d9fa8acff8
commit cde0d7d084
2 changed files with 43 additions and 7 deletions

View File

@ -201,10 +201,10 @@ implementation
*****************************************************************************} *****************************************************************************}
procedure firstassignment(var p : ptree); procedure firstassignment(var p : ptree);
{$ifdef dummyi386} {$ifdef newoptimizations}
var var
hp : ptree; hp : ptree;
{$endif} {$endif newoptimizations}
begin begin
{ must be made unique } { must be made unique }
set_unique(p^.left); set_unique(p^.left);
@ -273,8 +273,11 @@ implementation
{ the problem is for { the problem is for
s:=s+s+s; s:=s+s+s;
this is broken here !! } this is broken here !! }
{ while hp^.treetype=addn do hp:=hp^.left; {$ifdef newoptimizations}
if equal_trees(p^.left,hp) then hp := p^.right;
while hp^.treetype=addn do hp:=hp^.left;
if equal_trees(p^.left,hp) and
not multiple_uses(p^.left,p^.right) then
begin begin
p^.concat_string:=true; p^.concat_string:=true;
hp:=p^.right; hp:=p^.right;
@ -283,7 +286,8 @@ implementation
hp^.use_strconcat:=true; hp^.use_strconcat:=true;
hp:=hp^.left; hp:=hp^.left;
end; end;
end; } end;
{$endif newoptimizations}
end end
else else
begin begin
@ -486,7 +490,11 @@ implementation
end. end.
{ {
$Log$ $Log$
Revision 1.61 2000-02-24 18:41:39 peter Revision 1.62 2000-04-08 16:22:11 jonas
* fixed concat_string optimization and enabled it when
-dnewoptimizations is used
Revision 1.61 2000/02/24 18:41:39 peter
* removed warnings/notes * removed warnings/notes
Revision 1.60 2000/02/17 14:53:43 florian Revision 1.60 2000/02/17 14:53:43 florian

View File

@ -307,6 +307,10 @@ unit tree;
function getcopy(p : ptree) : ptree; function getcopy(p : ptree) : ptree;
function equal_trees(t1,t2 : ptree) : boolean; function equal_trees(t1,t2 : ptree) : boolean;
{$ifdef newoptimizations}
{ checks if t1 is loaded more than once in t2 and its sub-trees }
function multiple_uses(t1,t2: ptree): boolean;
{$endif newoptimizations}
procedure swaptree(p:Ptree); procedure swaptree(p:Ptree);
procedure disposetree(p : ptree); procedure disposetree(p : ptree);
@ -1731,6 +1735,26 @@ unit tree;
equal_trees:=false; equal_trees:=false;
end; end;
{$ifdef newoptimizations}
function multiple_uses(t1,t2: ptree): boolean;
var nr: longint;
procedure check_tree(t: ptree);
begin
inc(nr,ord(equal_trees(t1,t)));
if (nr < 2) and assigned(t^.left) then
check_tree(t^.left);
if (nr < 2) and assigned(t^.right) then
check_tree(t^.right);
end;
begin
nr := 0;
check_tree(t2);
multiple_uses := nr > 1;
end;
{$endif newoptimizations}
procedure set_unique(p : ptree); procedure set_unique(p : ptree);
begin begin
@ -2066,7 +2090,11 @@ unit tree;
end. end.
{ {
$Log$ $Log$
Revision 1.116 2000-03-01 15:36:12 florian Revision 1.117 2000-04-08 16:22:11 jonas
* fixed concat_string optimization and enabled it when
-dnewoptimizations is used
Revision 1.116 2000/03/01 15:36:12 florian
* some new stuff for the new cg * some new stuff for the new cg
Revision 1.115 2000/03/01 11:43:55 daniel Revision 1.115 2000/03/01 11:43:55 daniel