Raymond Toy pushed to branch master at cmucl / cmucl
Commits:
-
04225fe5
by Raymond Toy at 2024-03-22T09:55:30-07:00
-
274feae4
by Raymond Toy at 2024-03-22T09:58:37-07:00
-
b68de43f
by Raymond Toy at 2024-03-22T10:02:07-07:00
-
4ffad32e
by Raymond Toy at 2024-03-22T13:08:11-07:00
-
5538e622
by Raymond Toy at 2024-03-22T19:48:37-07:00
-
d82f9b92
by Raymond Toy at 2024-03-23T03:09:38+00:00
3 changed files:
Changes:
... | ... | @@ -731,7 +731,6 @@ |
731 | 731 | DONE))
|
732 | 732 | |
733 | 733 | |
734 | -;;; note documentation for this function is wrong - rtfm
|
|
735 | 734 | (define-vop (signed-byte-32-len)
|
736 | 735 | (:translate integer-length)
|
737 | 736 | (:note _N"inline (signed-byte 32) integer-length")
|
... | ... | @@ -747,12 +746,9 @@ |
747 | 746 | (inst not res)
|
748 | 747 | POS
|
749 | 748 | (inst bsr res res)
|
750 | - (inst jmp :z zero)
|
|
749 | + (inst jmp :z DONE)
|
|
751 | 750 | (inst inc res)
|
752 | 751 | (inst shl res 2)
|
753 | - (inst jmp done)
|
|
754 | - ZERO
|
|
755 | - (inst xor res res)
|
|
756 | 752 | DONE))
|
757 | 753 | |
758 | 754 | (define-vop (unsigned-byte-32-len)
|
... | ... | @@ -764,12 +760,11 @@ |
764 | 760 | (:results (res :scs (any-reg)))
|
765 | 761 | (:result-types positive-fixnum)
|
766 | 762 | (:generator 30
|
767 | - (move res arg)
|
|
768 | 763 | ;; The Intel docs say that BSR leaves the destination register
|
769 | - ;; undefined if the source is 0. But AMD64 says the destination
|
|
770 | - ;; register is unchanged. This also appears to be the case for
|
|
771 | - ;; GCC and LLVM.
|
|
772 | - (inst bsr res res)
|
|
764 | + ;; undefined if the source is 0. However, gcc, LLVM, and MSVC
|
|
765 | + ;; generate code that pretty much says BSR basically moves the
|
|
766 | + ;; source to the destination if the source is 0.
|
|
767 | + (inst bsr res arg)
|
|
773 | 768 | (inst jmp :z DONE)
|
774 | 769 | ;; The result of BSR is one too small for what we want, so
|
775 | 770 | ;; increment the result.
|
... | ... | @@ -61,6 +61,7 @@ public domain. |
61 | 61 | least-positive-float
|
62 | 62 | * ~~#278~~ Add some more debugging prints to gencgc
|
63 | 63 | * ~~#283~~ Add VOP for `integer-length` for `(unsigned-byte 32)` arg.
|
64 | + * ~~#284~~ Microoptimize `signed-byte-32-int-len` VOP for x86.
|
|
64 | 65 | * Other changes:
|
65 | 66 | * Improvements to the PCL implementation of CLOS:
|
66 | 67 | * Changes to building procedure:
|
1 | +;; Tests of integer functions
|
|
2 | + |
|
3 | +(defpackage :integer-tests
|
|
4 | + (:use :cl :lisp-unit))
|
|
5 | + |
|
6 | +(in-package "INTEGER-TESTS")
|
|
7 | + |
|
8 | +;; Simple functions for testing INTEGER-LENGTH for numbers of type
|
|
9 | +;; (unsigned-byte 32) and (signed-byte 32).
|
|
10 | +(defun integer-length-u32 (n)
|
|
11 | + (declare (type (unsigned-byte 32) n))
|
|
12 | + (integer-length n))
|
|
13 | + |
|
14 | +(defun integer-length-s32 (n)
|
|
15 | + (declare (type (signed-byte 32) n))
|
|
16 | + (integer-length n))
|
|
17 | + |
|
18 | +(define-test integer-length.unsigned-byte-32
|
|
19 | + (:tag :issues)
|
|
20 | + (assert-equal 0 (integer-length-u32 0))
|
|
21 | + (assert-equal 1 (integer-length-u32 1))
|
|
22 | + (assert-equal 31 (integer-length-u32 #x70000000))
|
|
23 | + (assert-equal 31 (integer-length-u32 #x7fffffff))
|
|
24 | + (assert-equal 32 (integer-length-u32 #xffffffff)))
|
|
25 | + |
|
26 | +(define-test integer-length.signed-byte-32
|
|
27 | + (:tag :issues)
|
|
28 | + (assert-equal 0 (integer-length-s32 0))
|
|
29 | + (assert-equal 1 (integer-length-s32 1))
|
|
30 | + (assert-equal 31 (integer-length-s32 #x70000000))
|
|
31 | + (assert-equal 31 (integer-length-s32 #x7fffffff))
|
|
32 | + (assert-equal 0 (integer-length-s32 -1))
|
|
33 | + (assert-equal 1 (integer-length-s32 -2))
|
|
34 | + (assert-equal 31 (integer-length-s32 #x-70000000))
|
|
35 | + (assert-equal 31 (integer-length-s32 #x-7fffffff))
|
|
36 | + (assert-equal 31 (integer-length-s32 #x-80000000)))
|
|
37 | + |
|
38 | + |