Raymond Toy pushed to branch master at cmucl / cmucl
Commits: 45d30576 by Raymond Toy at 2024-03-22T15:15:57+00:00 Fix #283: Add VOP for integer-length for an (unsigned-byte 32) arg
- - - - - 4d33af09 by Raymond Toy at 2024-03-22T15:15:58+00:00 Merge branch 'issue-283-unsigned-integer-length-vop' into 'master'
Fix #283: Add VOP for integer-length for an (unsigned-byte 32) arg
Closes #283
See merge request cmucl/cmucl!194 - - - - -
2 changed files:
- src/compiler/x86/arith.lisp - src/i18n/locale/cmucl-x86-vm.pot
Changes:
===================================== src/compiler/x86/arith.lisp ===================================== @@ -755,6 +755,28 @@ (inst xor res res) DONE))
+(define-vop (unsigned-byte-32-len) + (:translate integer-length) + (:note _N"inline (unsigned-byte 32) integer-length") + (:policy :fast-safe) + (:args (arg :scs (unsigned-reg))) + (:arg-types unsigned-num) + (:results (res :scs (any-reg))) + (:result-types positive-fixnum) + (:generator 30 + (move res arg) + ;; The Intel docs say that BSR leaves the destination register + ;; undefined if the source is 0. But AMD64 says the destination + ;; register is unchanged. This also appears to be the case for + ;; GCC and LLVM. + (inst bsr res res) + (inst jmp :z DONE) + ;; The result of BSR is one too small for what we want, so + ;; increment the result. + (inst inc res) + (inst shl res 2) + DONE)) + (define-vop (unsigned-byte-32-count) (:translate logcount) (:note _N"inline (unsigned-byte 32) logcount")
===================================== src/i18n/locale/cmucl-x86-vm.pot ===================================== @@ -296,6 +296,10 @@ msgstr "" msgid "inline (signed-byte 32) integer-length" msgstr ""
+#: src/compiler/x86/arith.lisp +msgid "inline (unsigned-byte 32) integer-length" +msgstr "" + #: src/compiler/x86/arith.lisp msgid "inline (unsigned-byte 32) logcount" msgstr ""
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/36299b0c96171700026c160...