Browse Source

* 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 -

nickysn 11 năm trước cách đây
mục cha
commit
34cf432600
1 tập tin đã thay đổi với 33 bổ sung26 xóa
  1. 33 26
      rtl/inc/int64.inc

+ 33 - 26
rtl/inc/int64.inc

@@ -310,39 +310,46 @@
          q1,q2,q3 : qword;
 
       begin
-           begin
-              sign:=false;
-              if f1<0 then
-                begin
-                   sign:=not(sign);
-                   q1:=qword(-f1);
-                end
-              else
-                q1:=f1;
-              if f2<0 then
-                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
+        { there's no difference between signed and unsigned multiplication,
+          when the destination size is equal to the source size and overflow
+          checking is off }
+        if not checkoverflow then
+          { qword(f1)*qword(f2) is coded as a call to mulqword }
+          fpc_mul_int64:=int64(qword(f1)*qword(f2))
+        else
+          begin
+            sign:=false;
+            if f1<0 then
+              begin
+                sign:=not(sign);
+                q1:=qword(-f1);
+              end
+            else
+              q1:=f1;
+            if f2<0 then
+              begin
+                sign:=not(sign);
+                q2:=qword(-f2);
+              end
+            else
+              q2:=f2;
+            { the q1*q2 is coded as call to mulqword }
+            q3:=q1*q2;
+
+            if (q1 <> 0) and (q2 <>0) and
               ((q1>q3) or (q2>q3) or
                 { the bit 63 can be only set if we have $80000000 00000000 }
                 { and sign is true                                         }
                 (q3 shr 63<>0) and
                  ((q3<>qword(qword(1) shl 63)) or not(sign))
                 ) then
-                HandleErrorAddrFrameInd(215,get_pc_addr,get_frame);
+              HandleErrorAddrFrameInd(215,get_pc_addr,get_frame);
 
-              if sign then
-                fpc_mul_int64:=-q3
-              else
-                fpc_mul_int64:=q3;
-           end;
+            if sign then
+              fpc_mul_int64:=-q3
+            else
+              fpc_mul_int64:=q3;
+          end;
       end;
 {$endif FPC_SYSTEM_HAS_MUL_INT64}