Removed unused function OPTIMIZE-C1LET*

This commit is contained in:
Juan Jose Garcia Ripoll 2010-05-13 10:38:57 +02:00
parent 9f842084bc
commit 7a9253ebad

View file

@ -293,76 +293,6 @@
(BDS-BIND)
(t (return T))))))
(defun optimize-c1let* (variables forms body)
;; since the body may produce type constraints on variables,
;; do it again:
(do ((vs variables (cdr vs))
(fs (nconc forms (list body)) (cdr fs))
(used-vars '())
(used-forms '()))
((null vs)
(values (nreverse used-vars) (nreverse used-forms)))
(let* ((var (first vs))
(form (and-form-type (var-type var) (car fs) (var-name var)
:unsafe "In LET* body"))
(form-type (c1form-primary-type form))
(rest-forms (cons body (rest fs))))
;; Automatic treatement for READ-ONLY variables:
(unless (or (global-var-p var)
(var-changed-in-form-list var rest-forms)
(var-functions-reading var)
(var-functions-setting var))
(setf (var-type var) form-type)
(update-var-type var form-type rest-forms)
;; * (let* ((v2 e2)) e3 e4) => (let () e3 e4)
;; provided
;; - v2 does not appear in body
;; - e2 produces no side effects
(when (and (= 0 (var-ref var))
(not (member (var-kind var) '(SPECIAL GLOBAL)))
(not (form-causes-side-effect form)))
(unless (var-ignorable var)
(cmpnote "Removing unused variable ~A" (var-name var)))
(go continue))
;; (let* ((v1 e1) (v2 e2) (v3 e3)) (expr e4 v2 e5))
;; can become
;; (let* ((v1 e1) (v3 e3)) (expr e4 e2 e5))
;; provided
;; - v2 appears only once
;; - v2 appears only in body
;; - e2 does not affect v1 nor e3, e3 does not affect e2
;; - e4 does not affect e2
(when (and (= 1 (var-ref var))
(var-referenced-in-form var body)
(not (form-causes-side-effect form))
;; it does not refer to special variables which
;; are changed in later assignments
(notany #'(lambda (v)
(var-referenced-in-form v form))
(rest vs))
(or (and (null (rest vs)) ; last variable
;; its form does not affect previous variables
(let ((tforms (list form)))
(dolist (v variables)
(when (eq v var) (return t))
(when (var-changed-in-form-list v tforms)
(return nil)))))
(not (args-cause-side-effect fs)))
(replaceable var fs))
(cmpnote "Replacing variable ~A by its value ~a" (var-name var) form)
(nsubst-var var form)
(go continue))
)
#+nil
;; Force unboxing
(when (member-type (c1form-primary-type form)
'(FIXNUM CHARACTER DOUBLE-FLOAT SINGLE-FLOAT))
(incf (var-ref var)))
(check-vref var)
(push var used-vars)
(push form used-forms))
continue))
;; should check whether a form before var causes a side-effect
;; exactly one occurrence of var is present in forms
(defun replaceable (var form)