Last active
January 17, 2019 19:00
-
-
Save stassats/f79b0c6fb9b72acfad33e8cf4e84d41d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun foo (f a b) | |
(declare (optimize (debug 1))) | |
(labels ((fun (z) | |
(let ((m z)) | |
;; delays type derivation of FUN as FIXNUM until constraint propagation | |
;; making sure SUBSTITUTE-SINGLE-USE-LVAR runs first. | |
(if (typep m 'fixnum) | |
m | |
0)))) | |
(declare (inline fun)) | |
(let* ((a (fun a)) | |
(b (fun b))) | |
(let ((m | |
(if f | |
;; Two casts, SUBSTITUTE-SINGLE-USE-LVAR looks just | |
;; for one cast having multiple destinatations | |
;; And after constraint propagation the casts are | |
;; deleted and A and B go to the same LVAR, at the | |
;; same time. | |
(truly-the fixnum (truly-the integer a)) | |
(truly-the fixnum (truly-the integer b))))) | |
m)))) | |
(list (foo t 1 2) (foo nil 1 2)) => (2 2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun foo (f) | |
(declare (optimize (debug 1))) | |
(let* ((a (eval 1)) | |
(b (eval 2))) | |
(multiple-value-bind (x y) (if f | |
(values a 1) | |
(values b 2)) | |
(values x y)))) | |
(defun foo (f) | |
(declare (optimize (debug 1))) | |
(let* ((a (eval 1)) | |
(b (eval 2)) | |
(m (if f | |
(values a) | |
(values b)))) | |
m)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment