mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-13 11:09:13 +02:00
* in the generic implementation of fpc_mul_int64, fallback directly to
fpc_mul_qword directly in case overflow checking is not used git-svn-id: trunk@26483 -
This commit is contained in:
parent
e210d5f30e
commit
34cf432600
@ -310,39 +310,46 @@
|
|||||||
q1,q2,q3 : qword;
|
q1,q2,q3 : qword;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
begin
|
{ there's no difference between signed and unsigned multiplication,
|
||||||
sign:=false;
|
when the destination size is equal to the source size and overflow
|
||||||
if f1<0 then
|
checking is off }
|
||||||
begin
|
if not checkoverflow then
|
||||||
sign:=not(sign);
|
{ qword(f1)*qword(f2) is coded as a call to mulqword }
|
||||||
q1:=qword(-f1);
|
fpc_mul_int64:=int64(qword(f1)*qword(f2))
|
||||||
end
|
else
|
||||||
else
|
begin
|
||||||
q1:=f1;
|
sign:=false;
|
||||||
if f2<0 then
|
if f1<0 then
|
||||||
begin
|
begin
|
||||||
sign:=not(sign);
|
sign:=not(sign);
|
||||||
q2:=qword(-f2);
|
q1:=qword(-f1);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
q2:=f2;
|
q1:=f1;
|
||||||
{ the q1*q2 is coded as call to mulqword }
|
if f2<0 then
|
||||||
q3:=q1*q2;
|
begin
|
||||||
|
sign:=not(sign);
|
||||||
|
q2:=qword(-f2);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
q2:=f2;
|
||||||
|
{ the q1*q2 is coded as call to mulqword }
|
||||||
|
q3:=q1*q2;
|
||||||
|
|
||||||
if checkoverflow and (q1 <> 0) and (q2 <>0) and
|
if (q1 <> 0) and (q2 <>0) and
|
||||||
((q1>q3) or (q2>q3) or
|
((q1>q3) or (q2>q3) or
|
||||||
{ the bit 63 can be only set if we have $80000000 00000000 }
|
{ the bit 63 can be only set if we have $80000000 00000000 }
|
||||||
{ and sign is true }
|
{ and sign is true }
|
||||||
(q3 shr 63<>0) and
|
(q3 shr 63<>0) and
|
||||||
((q3<>qword(qword(1) shl 63)) or not(sign))
|
((q3<>qword(qword(1) shl 63)) or not(sign))
|
||||||
) then
|
) then
|
||||||
HandleErrorAddrFrameInd(215,get_pc_addr,get_frame);
|
HandleErrorAddrFrameInd(215,get_pc_addr,get_frame);
|
||||||
|
|
||||||
if sign then
|
if sign then
|
||||||
fpc_mul_int64:=-q3
|
fpc_mul_int64:=-q3
|
||||||
else
|
else
|
||||||
fpc_mul_int64:=q3;
|
fpc_mul_int64:=q3;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
{$endif FPC_SYSTEM_HAS_MUL_INT64}
|
{$endif FPC_SYSTEM_HAS_MUL_INT64}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user