From 98bd768521440aded9856b7f8027dcd5028e9e2c Mon Sep 17 00:00:00 2001 From: florian Date: Sat, 24 Feb 2018 23:13:27 +0000 Subject: [PATCH] * remove type cast of the parameter of int(...), if an instruction is available which can be used directly git-svn-id: trunk@38335 - --- compiler/x86/nx86inl.pas | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/compiler/x86/nx86inl.pas b/compiler/x86/nx86inl.pas index e7a62ad546..0f9bff5235 100644 --- a/compiler/x86/nx86inl.pas +++ b/compiler/x86/nx86inl.pas @@ -51,6 +51,9 @@ interface function first_fma: tnode; override; function first_frac_real : tnode; override; function first_int_real : tnode; override; + + function simplify(forinline : boolean) : tnode; override; + { second pass override to generate these nodes } procedure second_IncludeExclude;override; procedure second_pi; override; @@ -83,8 +86,9 @@ implementation verbose,compinnr, defutil, aasmbase,aasmdata,aasmcpu, - symtype,symdef,symcpu, - cgbase,pass_2, + symconst,symtype,symdef,symcpu, + ncnv, + cgbase,pass_1,pass_2, cpuinfo,cpubase,nutils, ncal,ncgutil, tgobj, @@ -281,6 +285,7 @@ implementation if (current_settings.fputype>=fpu_sse41) and ((is_double(resultdef)) or (is_single(resultdef))) then begin + maybe_remove_round_trunc_typeconv; expectloc:=LOC_MMREGISTER; Result:=nil; end @@ -294,14 +299,38 @@ implementation if (current_settings.fputype>=fpu_sse41) and ((is_double(resultdef)) or (is_single(resultdef))) then begin - expectloc:=LOC_MMREGISTER; Result:=nil; + expectloc:=LOC_MMREGISTER; end else Result:=inherited first_int_real; end; + function tx86inlinenode.simplify(forinline : boolean) : tnode; + var + temp : tnode; + begin + if (current_settings.fputype>=fpu_sse41) and + (inlinenumber=in_int_real) and (left.nodetype=typeconvn) and + not(nf_explicit in left.flags) and + (ttypeconvnode(left).left.resultdef.typ=floatdef) and + ((is_double(ttypeconvnode(left).left.resultdef)) or (is_single(ttypeconvnode(left).left.resultdef))) then + begin + { get rid of the type conversion } + temp:=ttypeconvnode(left).left; + ttypeconvnode(left).left:=nil; + left.free; + left:=temp; + result:=self.getcopy; + tinlinenode(result).resultdef:=temp.resultdef; + typecheckpass(result); + end + else + Result:=inherited simplify(forinline); + end; + + procedure tx86inlinenode.second_pi; begin location_reset(location,LOC_FPUREGISTER,def_cgsize(resultdef));