Skip to content

Commit c03ba8b

Browse files
committed
Turn ENDP compiler macro into a transform
Fixing more bytecode incompatibilities.
1 parent bbdda21 commit c03ba8b

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

src/lisp/kernel/cleavir/transform.lisp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,9 +548,19 @@ Optimizations are available for any of:
548548
0
549549
(core:cons-length x)))
550550

551-
(deftransform-type-predicate endp null)
552551
(deftransform-type-predicate null null)
553552

553+
(deftransform endp (((x (not list))))
554+
'(error 'type-error :datum x :expected-type 'list))
555+
(deftransform endp (((x list))) '(null x))
556+
;; These two are technically redundant since null has a transform,
557+
;; but we might as well simplify in one shot, no?
558+
(deftransform endp (((x null))) t)
559+
(deftransform endp (((x cons))) nil)
560+
;; If all else fails,
561+
(deftransform endp (((x t)))
562+
'(null (the (values list &rest nil) x)))
563+
554564
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
555565
;;;
556566
;;; (15) ARRAYS

src/lisp/kernel/cmp/opt/opt-cons.lisp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@
1717
(t form)))
1818

1919
(define-compiler-macro null (object) `(if ,object nil t))
20-
#-bytecode
21-
(define-compiler-macro endp (object)
22-
;; awkward THE to prevent very inefficient arbitrary-values type check in cclasp
23-
;; see the notes in opt-number for a little more information
24-
`(if (the (values list &rest nil) (values ,object)) nil t))
2520

2621
(defconstant +nthcdr-inline-limit+ 8) ; totally arbitrary
2722

0 commit comments

Comments
 (0)