* implement branchless fpc_abs_long in a generic way

* enable optimization for ppc/ppc64 (two times faster than 
"generic" rtl branching routine)

git-svn-id: trunk@10306 -
This commit is contained in:
tom_at_work 2008-02-11 21:13:52 +00:00
parent f8c9052c21
commit 52135af71f
3 changed files with 18 additions and 3 deletions

View File

@ -600,8 +600,23 @@ implementation
end;
procedure tcginlinenode.second_abs_long;
var
opsize : tcgsize;
tempreg1, tempreg2 : tregister;
begin
internalerror(200711251);
opsize := def_cgsize(left.resultdef);
secondpass(left);
location_force_reg(current_asmdata.CurrAsmList, left.location, opsize, false);
location := left.location;
location.register := cg.getintregister(current_asmdata.CurrAsmList, opsize);
tempreg1 := cg.getintregister(current_asmdata.CurrAsmList, opsize);
tempreg2 := cg.getintregister(current_asmdata.CurrAsmList, opsize);
cg.a_op_const_reg_reg(current_asmdata.CurrAsmList, OP_SAR, OS_INT, tcgsize2size[opsize]*8-1, left.location.register, tempreg1);
cg.a_op_reg_reg_reg(current_asmdata.CurrAsmList, OP_XOR, OS_INT, left.location.register, tempreg1, tempreg2);
cg.a_op_reg_reg_reg(current_asmdata.CurrAsmlist, OP_SUB, OS_INT, tempreg1, tempreg2, location.register);
end;

View File

@ -2148,7 +2148,7 @@ begin
def_system_macro('FPC_NEW_BIGENDIAN_SETS');
def_system_macro('FPC_STRTOSHORTSTRINGPROC');
def_system_macro('FPC_OBJFPC_EXTENDED_IF');
{$ifdef x86}
{$if defined(x86) or defined(powerpc) or defined(powerpc64)}
def_system_macro('FPC_HAS_INTERNAL_ABS_LONG');
{$endif}

View File

@ -482,7 +482,7 @@ Function Random: extended;
Procedure Randomize;
{$endif FPC_HAS_FEATURE_RANDOM}
{$ifdef FPC_HAS_INTERNAL_ABS_LONG and (defined(cpui386) or defined(cpux86_64))}
{$ifdef FPC_HAS_INTERNAL_ABS_LONG and (defined(cpui386) or defined(cpux86_64) or defined(cpupowerpc))}
{$define FPC_SYSTEM_HAS_ABS_LONGINT}
Function abs(l:longint):longint;[internproc:fpc_in_abs_long];
{$else FPC_HAS_INTERNAL_ABS_LONG}