* On 64-bit targets, handle abs(int64) internally, using the same code as for abs(longint), i.e. without branching. Both generic and x86-specific pass 2 code is already suitable for different operand sizes, only type checking needs removal of excessive conversions to 32 bits.

git-svn-id: trunk@27989 -
This commit is contained in:
sergei 2014-06-17 18:45:11 +00:00
parent 5e7a4c4819
commit 04d8e8a5dc
3 changed files with 11 additions and 4 deletions

View File

@ -2412,9 +2412,9 @@ implementation
if left.nodetype=ordconstn then if left.nodetype=ordconstn then
begin begin
if tordconstnode(left).value<0 then if tordconstnode(left).value<0 then
result:=cordconstnode.create((-tordconstnode(left).value),s32inttype,false) result:=cordconstnode.create((-tordconstnode(left).value),resultdef,false)
else else
result:=cordconstnode.create((tordconstnode(left).value),s32inttype,false); result:=cordconstnode.create((tordconstnode(left).value),resultdef,false);
end end
end; end;
in_sqr_real : in_sqr_real :
@ -3139,8 +3139,7 @@ implementation
in_abs_long: in_abs_long:
begin begin
set_varstate(left,vs_read,[vsf_must_be_valid]); set_varstate(left,vs_read,[vsf_must_be_valid]);
inserttypeconv(left,s32inttype); resultdef:=left.resultdef;
resultdef:=s32inttype;
end; end;
in_abs_real, in_abs_real,

View File

@ -2939,6 +2939,9 @@ begin
{ abs(long) is handled internally on all CPUs } { abs(long) is handled internally on all CPUs }
def_system_macro('FPC_HAS_INTERNAL_ABS_LONG'); def_system_macro('FPC_HAS_INTERNAL_ABS_LONG');
{$if defined(x86_64) or defined(powerpc64)}
def_system_macro('FPC_HAS_INTERNAL_ABS_INT64');
{$endif x86_64 or powerpc64}
def_system_macro('FPC_HAS_UNICODESTRING'); def_system_macro('FPC_HAS_UNICODESTRING');
def_system_macro('FPC_RTTI_PACKSET1'); def_system_macro('FPC_RTTI_PACKSET1');

View File

@ -797,7 +797,12 @@ Function abs(l:longint):longint;[internproc:fpc_in_abs_long];
{$else FPC_HAS_INTERNAL_ABS_LONG} {$else FPC_HAS_INTERNAL_ABS_LONG}
Function abs(l:Longint):Longint;[internconst:fpc_in_const_abs];{$ifdef SYSTEMINLINE}inline;{$endif} Function abs(l:Longint):Longint;[internconst:fpc_in_const_abs];{$ifdef SYSTEMINLINE}inline;{$endif}
{$endif FPC_HAS_INTERNAL_ABS_LONG} {$endif FPC_HAS_INTERNAL_ABS_LONG}
{$ifdef FPC_HAS_INTERNAL_ABS_INT64}
{$define FPC_SYSTEM_HAS_ABS_INT64}
Function abs(l:Int64):Int64;[internproc:fpc_in_abs_long];
{$else FPC_HAS_INTERNAL_ABS_INT64}
Function abs(l:Int64):Int64;[internconst:fpc_in_const_abs];{$ifdef SYSTEMINLINE}inline;{$endif} Function abs(l:Int64):Int64;[internconst:fpc_in_const_abs];{$ifdef SYSTEMINLINE}inline;{$endif}
{$endif FPC_HAS_INTERNAL_ABS_INT64}
Function sqr(l:Longint):Longint;[internconst:fpc_in_const_sqr];{$ifdef SYSTEMINLINE}inline;{$endif} Function sqr(l:Longint):Longint;[internconst:fpc_in_const_sqr];{$ifdef SYSTEMINLINE}inline;{$endif}
Function sqr(l:Int64):Int64;[internconst:fpc_in_const_sqr];{$ifdef SYSTEMINLINE}inline;{$endif} Function sqr(l:Int64):Int64;[internconst:fpc_in_const_sqr];{$ifdef SYSTEMINLINE}inline;{$endif}
Function sqr(l:QWord):QWord;[internconst:fpc_in_const_sqr];{$ifdef SYSTEMINLINE}inline;{$endif} Function sqr(l:QWord):QWord;[internconst:fpc_in_const_sqr];{$ifdef SYSTEMINLINE}inline;{$endif}