From 13f1fb60b4cc7ee884a00de755d983ae0790bb6e Mon Sep 17 00:00:00 2001 From: florian Date: Tue, 27 Oct 2020 21:42:51 +0000 Subject: [PATCH] * directly copy the result of set set into the left side of an assignment git-svn-id: trunk@47226 - --- compiler/nadd.pas | 63 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 43 insertions(+), 20 deletions(-) diff --git a/compiler/nadd.pas b/compiler/nadd.pas index 067bc22e2b..5f808a70a9 100644 --- a/compiler/nadd.pas +++ b/compiler/nadd.pas @@ -3272,29 +3272,52 @@ implementation newstatement : tstatementnode; temp : ttempcreatenode; begin - { add two var sets } - result:=internalstatements(newstatement); + { directly load the result set into the assignee if possible } + 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 } - temp:=ctempcreatenode.create(resultdef,resultdef.size,tt_persistent,true); - addstatement(newstatement,temp); + { remove reused parts from original node } + left:=nil; + right:=nil; - addstatement(newstatement,ccallnode.createintern(n, - ccallparanode.create(cordconstnode.create(resultdef.size,sinttype,false), - ccallparanode.create(ctemprefnode.create(temp), - ccallparanode.create(right, - ccallparanode.create(left,nil))))) - ); + include(aktassignmentnode.flags,nf_assign_done_in_right); + firstpass(result); + end + else + begin + { add two var sets } + result:=internalstatements(newstatement); - { 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)); + { create temp for result } + temp:=ctempcreatenode.create(resultdef,resultdef.size,tt_persistent,true); + addstatement(newstatement,temp); + + addstatement(newstatement,ccallnode.createintern(n, + ccallparanode.create(cordconstnode.create(resultdef.size,sinttype,false), + ccallparanode.create(ctemprefnode.create(temp), + ccallparanode.create(right, + 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; var