> > So to better optimise the original program with regular optimisation > options, I guess we need a) full SSA support
Yes. > b) better (node) CSE > support Enabling node cse on loadparentfpn nodes helps already slightly: diff a/compiler/ncgld.pas b/compiler/ncgld.pas index 028e51e..1ab6f11 100644 --- a/compiler/ncgld.pas +++ b/compiler/ncgld.pas @@ -410,7 +410,7 @@ implementation if assigned(left) then begin secondpass(left); - if left.location.loc<>LOC_REGISTER then + if not(left.location.loc in [LOC_REGISTER,LOC_CREGISTER]) then internalerror(200309286); if vs.localloc.loc<>LOC_REFERENCE then internalerror(200409241); diff a/compiler/nutils.pas b/compiler/nutils.pas --- a/compiler/nutils.pas +++ b/compiler/nutils.pas @@ -703,6 +703,8 @@ implementation end; loadn: begin + if assigned(tloadnode(p).left) then + inc(result,node_complexity(tloadnode(p).left)); { threadvars need a helper call } if (tloadnode(p).symtableentry.typ=staticvarsym) and (vo_is_thread_var in tstaticvarsym(tloadnode(p).symtableentry).varoptions) then diff a/compiler/optcse.pas b/compiler/optcse.pas --- a/compiler/optcse.pas +++ b/compiler/optcse.pas @@ -65,7 +65,7 @@ unit optcse; cseinvariant : set of tnodetype = [loadn,addn,muln,subn,divn,slashn,modn,andn,orn,xorn,notn,vecn, derefn,equaln,unequaln,ltn,gtn,lten,gten,typeconvn,subscriptn, inn,symdifn,shrn,shln,ordconstn,realconstn,unaryminusn,pointerconstn,stringconstn,setconstn, - isn,asn,starstarn,nothingn,temprefn {,callparan}]; + isn,asn,starstarn,nothingn,temprefn,loadparentfpn {,callparan}]; function searchsubdomain(var n:tnode; arg: pointer) : foreachnoderesult; begin Enabling it on dyn. array expressions could help further in theory, if the compiler would know that no addref/decref code is needed in this case for the temp. dyn. array variables :) _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal