mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-13 21:49:11 +02:00
* fix and suppress some rangecheck/overflow errors (regarding calculation
of magic constants for changing division into multiplication) git-svn-id: trunk@2653 -
This commit is contained in:
parent
23b5138f78
commit
7f247e9305
@ -61,6 +61,15 @@ implementation
|
|||||||
cpubase,
|
cpubase,
|
||||||
ncgutil,cgcpu;
|
ncgutil,cgcpu;
|
||||||
|
|
||||||
|
{$ifopt r+}
|
||||||
|
{$r-}
|
||||||
|
{$define rangeon}
|
||||||
|
{$endif}
|
||||||
|
|
||||||
|
{$ifopt q+}
|
||||||
|
{$r-}
|
||||||
|
{$define overflowon}
|
||||||
|
{$endif}
|
||||||
{ helper functions }
|
{ helper functions }
|
||||||
procedure getmagic_unsigned32(d : dword; out magic_m : dword; out magic_add : boolean; out magic_shift : dword);
|
procedure getmagic_unsigned32(d : dword; out magic_m : dword; out magic_add : boolean; out magic_shift : dword);
|
||||||
var
|
var
|
||||||
@ -144,6 +153,16 @@ begin
|
|||||||
magic_s := p - 32; { resulting shift }
|
magic_s := p - 32; { resulting shift }
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{$ifdef rangeon}
|
||||||
|
{$r+}
|
||||||
|
{$undef rangeon}
|
||||||
|
{$endif}
|
||||||
|
|
||||||
|
{$ifdef overflowon}
|
||||||
|
{$q+}
|
||||||
|
{$undef overflowon}
|
||||||
|
{$endif}
|
||||||
|
|
||||||
{*****************************************************************************
|
{*****************************************************************************
|
||||||
TPPCMODDIVNODE
|
TPPCMODDIVNODE
|
||||||
*****************************************************************************}
|
*****************************************************************************}
|
||||||
@ -226,7 +245,7 @@ end;
|
|||||||
end else begin
|
end else begin
|
||||||
getmagic_unsigned32(tordconstnode(right).value, u_magic, u_add, u_shift);
|
getmagic_unsigned32(tordconstnode(right).value, u_magic, u_add, u_shift);
|
||||||
// load magic in divreg
|
// load magic in divreg
|
||||||
cg.a_load_const_reg(exprasmlist, OS_INT, u_magic, divreg);
|
cg.a_load_const_reg(exprasmlist, OS_INT, aint(u_magic), divreg);
|
||||||
exprasmlist.concat(taicpu.op_reg_reg_reg(A_MULHWU, resultreg, numerator, divreg));
|
exprasmlist.concat(taicpu.op_reg_reg_reg(A_MULHWU, resultreg, numerator, divreg));
|
||||||
if (u_add) then begin
|
if (u_add) then begin
|
||||||
cg.a_op_reg_reg_reg(exprasmlist, OP_SUB, OS_INT, resultreg, numerator, divreg);
|
cg.a_op_reg_reg_reg(exprasmlist, OP_SUB, OS_INT, resultreg, numerator, divreg);
|
||||||
|
Loading…
Reference in New Issue
Block a user