[Git][cmucl/cmucl][master] Support constant shifts for bignum digits.

Raymond Toy rtoy at common-lisp.net
Sun Nov 29 00:44:42 UTC 2015


Raymond Toy pushed to branch master at cmucl / cmucl


Commits:
5d3a63fa by Raymond Toy at 2015-11-28T16:43:54Z
Support constant shifts for bignum digits.

This gets rid of the load of the shift amount to ecx, saving one
instruction and reducing pressure on the ecx register.

- - - - -


1 changed file:

- src/compiler/x86/arith.lisp


Changes:

=====================================
src/compiler/x86/arith.lisp
=====================================
--- a/src/compiler/x86/arith.lisp
+++ b/src/compiler/x86/arith.lisp
@@ -1445,31 +1445,43 @@
   (:translate bignum::%ashr)
   (:policy :fast-safe)
   (:args (digit :scs (unsigned-reg unsigned-stack) :target result)
-	 (count :scs (unsigned-reg) :target ecx))
+	 (count :scs (unsigned-reg immediate)))
   (:arg-types unsigned-num positive-fixnum)
   (:temporary (:sc unsigned-reg :offset ecx-offset :from (:argument 1)) ecx)
   (:results (result :scs (unsigned-reg) :from (:argument 0)
 		    :load-if (not (and (sc-is result unsigned-stack)
 				       (location= digit result)))))
   (:result-types unsigned-num)
-  (:generator 1
+  (:generator 2
     (move result digit)
-    (move ecx count)
-    (inst sar result :cl)))
+    (sc-case count
+      (unsigned-reg
+       (move ecx count)
+       (inst sar result :cl))
+      (immediate
+       (inst sar result (tn-value count))))))
 
 (define-vop (digit-lshr digit-ashr)
   (:translate bignum::%digit-logical-shift-right)
-  (:generator 1
+  (:generator 2
     (move result digit)
-    (move ecx count)
-    (inst shr result :cl)))
+    (sc-case count
+      (unsigned-reg
+       (move ecx count)
+       (inst shr result :cl))
+      (immediate
+       (inst shr result (tn-value count))))))
 
 (define-vop (digit-ashl digit-ashr)
   (:translate bignum::%ashl)
-  (:generator 1
+  (:generator 2
     (move result digit)
-    (move ecx count)
-    (inst shl result :cl)))
+    (sc-case count
+      (unsigned-reg
+       (move ecx count)
+       (inst shl result :cl))
+      (immediate
+       (inst shl result (tn-value count))))))
 
 

 ;;;; Static functions.



View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/commit/5d3a63fa223ea40f8625a47d367d13b8c85c0842
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/cmucl-cvs/attachments/20151129/081dab72/attachment.html>


More information about the cmucl-cvs mailing list