* directly copy the result of set <op> set into the left side of an assignment

git-svn-id: trunk@47226 -
This commit is contained in:
florian 2020-10-27 21:42:51 +00:00
parent eb4bc9d153
commit 13f1fb60b4

View File

@ -3272,29 +3272,52 @@ implementation
newstatement : tstatementnode; newstatement : tstatementnode;
temp : ttempcreatenode; temp : ttempcreatenode;
begin begin
{ add two var sets } { directly load the result set into the assignee if possible }
result:=internalstatements(newstatement); if assigned(aktassignmentnode) and
(aktassignmentnode.right=self) and
(aktassignmentnode.left.resultdef=resultdef) and
valid_for_var(aktassignmentnode.left,false) then
begin
result:=ccallnode.createintern(n,
ccallparanode.create(cordconstnode.create(resultdef.size,sinttype,false),
ccallparanode.create(aktassignmentnode.left.getcopy,
ccallparanode.create(right,
ccallparanode.create(left,nil))))
);
{ create temp for result } { remove reused parts from original node }
temp:=ctempcreatenode.create(resultdef,resultdef.size,tt_persistent,true); left:=nil;
addstatement(newstatement,temp); right:=nil;
addstatement(newstatement,ccallnode.createintern(n, include(aktassignmentnode.flags,nf_assign_done_in_right);
ccallparanode.create(cordconstnode.create(resultdef.size,sinttype,false), firstpass(result);
ccallparanode.create(ctemprefnode.create(temp), end
ccallparanode.create(right, else
ccallparanode.create(left,nil))))) begin
); { add two var sets }
result:=internalstatements(newstatement);
{ remove reused parts from original node } { create temp for result }
left:=nil; temp:=ctempcreatenode.create(resultdef,resultdef.size,tt_persistent,true);
right:=nil; addstatement(newstatement,temp);
{ the last statement should return the value as
location and type, this is done be referencing the addstatement(newstatement,ccallnode.createintern(n,
temp and converting it first from a persistent temp to ccallparanode.create(cordconstnode.create(resultdef.size,sinttype,false),
normal temp } ccallparanode.create(ctemprefnode.create(temp),
addstatement(newstatement,ctempdeletenode.create_normal_temp(temp)); ccallparanode.create(right,
addstatement(newstatement,ctemprefnode.create(temp)); ccallparanode.create(left,nil)))))
);
{ remove reused parts from original node }
left:=nil;
right:=nil;
{ the last statement should return the value as
location and type, this is done be referencing the
temp and converting it first from a persistent temp to
normal temp }
addstatement(newstatement,ctempdeletenode.create_normal_temp(temp));
addstatement(newstatement,ctemprefnode.create(temp));
end;
end; end;
var var