Raymond Toy pushed to branch issue-397-const-mult-using-lea at cmucl / cmucl
Commits:
-
6250a035
by Raymond Toy at 2025-04-02T08:44:08-07:00
-
e8e4d22b
by Raymond Toy at 2025-04-02T08:45:13-07:00
2 changed files:
Changes:
... | ... | @@ -295,7 +295,8 @@ |
295 | 295 | ;; temp = x*8
|
296 | 296 | ;; r = temp - x
|
297 | 297 | (inst lea ,temp (make-ea :dword :index ,x :scale 8))
|
298 | - (inst sub ,temp ,x))
|
|
298 | + (inst sub ,temp ,x)
|
|
299 | + (move ,r ,temp))
|
|
299 | 300 | ((= ,y 9)
|
300 | 301 | ;; r = x + x*8
|
301 | 302 | (inst lea ,r (make-ea :dword :base ,x :index ,x :scale 8)))
|
1 | +;; Test x86 multiplication by small constants
|
|
2 | + |
|
3 | +(defpackage :arith-tests
|
|
4 | + (:use :cl :lisp-unit))
|
|
5 | + |
|
6 | +(in-package "ARITH-TESTS")
|
|
7 | + |
|
8 | +#+x86
|
|
9 | +(macrolet
|
|
10 | + ((frob (c arg expected)
|
|
11 | + (let ((test-name-fixnum (intern (format nil "X86-TEST-CONST-MUL-FIXNUM-~D" c))))
|
|
12 | + `(define-test ,test-name-fixnum
|
|
13 | + (:tag :x86-arith)
|
|
14 | + (assert-eql ,expected
|
|
15 | + (funcall (compile nil #'(lambda (x)
|
|
16 | + (declare (type (signed-byte 24) x))
|
|
17 | + (* x ,c)))
|
|
18 | + ,arg))))))
|
|
19 | + ;; This is a test of #397. Test that the multiplication by small
|
|
20 | + ;; constants is correct for each of the constants defined for the
|
|
21 | + ;; fixnum-*-c/fixnum=>fixnum vop.
|
|
22 | + |
|
23 | + (frob 2 10 20)
|
|
24 | + (frob 2 -10 -20)
|
|
25 | + (frob 3 10 30)
|
|
26 | + (frob 3 -10 -30)
|
|
27 | + (frob 4 10 40)
|
|
28 | + (frob 4 -10 -40)
|
|
29 | + (frob 5 10 50)
|
|
30 | + (frob 5 -10 -50)
|
|
31 | + (frob 6 10 60)
|
|
32 | + (frob 6 -10 -60)
|
|
33 | + (frob 7 10 70)
|
|
34 | + (frob 7 -10 -70)
|
|
35 | + (frob 8 10 80)
|
|
36 | + (frob 8 -10 -80)
|
|
37 | + (frob 9 10 90)
|
|
38 | + (frob 9 -10 -90)
|
|
39 | + (frob 10 10 100)
|
|
40 | + (frob 10 -10 -100)
|
|
41 | + (frob 11 10 110)
|
|
42 | + (frob 11 -10 -110)
|
|
43 | + (frob 12 10 120)
|
|
44 | + (frob 12 -10 -120)
|
|
45 | + (frob 13 10 130)
|
|
46 | + (frob 13 -10 -130)) |