Changeset 15051


Ignore:
Timestamp:
Oct 30, 2011, 8:24:41 AM (8 years ago)
Author:
gb
Message:

nx2.lisp: New function NX2-VAR-NOT-REFFED-BY-FORM-P. Walks acode, returns
true iff it's sure that acode doesn't reference the specifed VAR.

x862.lisp: in the fixed-arg tail-call case of X862-SELF-CALL, don't
process arguments whose value isn't changing between the caller and
callee. If argument values are ultimately going to wind up in NVRs,
try to get them there directly. (This is only safe if no subequently-
processed argument values reference or set the variable's value. Setting
the NVR changes that value, and N-TARGETED-REG-FORMs isn't used to dealing
with that side-effect.)

Location:
trunk/source/compiler
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/compiler/X86/x862.lisp

    r15050 r15051  
    10011001            *x862-trust-declarations* (neq 0 (%ilogand2 $decl_trustdecls decls))))))
    10021002
    1003 
     1003(defun x862-nvr-p (reg)
     1004  (target-arch-case
     1005   (:x8664
     1006    ;; For the sake of argument, x8664::save3 is always an nvr (even though
     1007    ;; we have to keep the TCR in it on some platforms.)
     1008    (and (node-reg-p reg) (logbitp (hard-regspec-value reg) x8664-nonvolatile-registers-mask)))
     1009   (:x8632
     1010    ;; We might have some caller-save NVRs on x8632 someday, but for now:
     1011    nil)))
    10041012   
    10051013;;; Vpush the last N non-volatile-registers.
     
    75367544                                       ($ x8664::arg_y)
    75377545                                       ($ x8664::arg_z))))))))
     7546        ;; A form that's a lexical reference to X that's ultimately going
     7547        ;; to be stored in X is a noop.
     7548        (collect ((new-forms)
     7549                  (new-vars)
     7550                  (new-regs))
     7551          (do* ((xforms forms (cdr xforms))
     7552                (xvars vars (cdr xvars))
     7553                (xregs regs (cdr xregs))
     7554                (new-nargs 0))
     7555               ((null xforms)
     7556                (setq nargs new-nargs
     7557                      forms (new-forms)
     7558                      vars (new-vars)
     7559                      regs (new-regs)))
     7560            (declare (fixnum new-nargs))
     7561            (let* ((var (car xvars))
     7562                   (form (car xforms)))
     7563              (unless (and (eq var (nx2-lexical-reference-p form))
     7564                           (not (logbitp $vbitsetq (nx-var-bits var))))
     7565                (incf new-nargs)
     7566                (new-vars var)
     7567                (new-forms form)
     7568                (new-regs (car xregs))))))
     7569        (dotimes (i nargs)
     7570          (let* ((var (nth i vars))
     7571                 (nvr (var-nvr var)))
     7572            (when nvr
     7573              (when (dotimes (j nargs t)
     7574                      (unless (= i j)
     7575                        (let* ((form (nth j forms)))
     7576                          (unless (and (nx2-var-not-set-by-form-p var form)
     7577                                       (nx2-var-not-reffed-by-form-p var form))
     7578                            (return)))))
     7579                (setf (nth i regs) nvr)))))
    75387580        (case nargs
    75397581          (1 (x862-one-targeted-reg-form seg (car forms) (car regs)))
  • trunk/source/compiler/nx2.lisp

    r15050 r15051  
    227227                        (not-set-in-formlist (cadr subforms))))))))))
    228228
     229(defun nx2-var-not-reffed-by-form-p (var form &optional closed)
     230  (setq form (acode-unwrapped-form form))
     231  (unless (eq var (nx2-lexical-reference-p form))
     232    (or (atom form)
     233        (nx2-lexical-reference-p form)  ;not us
     234        (nx2-constant-form-p form)
     235        (let ((op (acode-operator form))
     236              (subforms nil))
     237          (if (eq op (%nx1-operator setq-lexical))
     238            (and (neq var (cadr form))
     239                 (nx2-var-not-reffed-by-form-p var (caddr form)))
     240            (and (or (not closed)
     241                     (logbitp operator-side-effect-free-bit op))
     242                 (flet ((not-reffed-in-formlist (formlist)
     243                          (dolist (subform formlist t)
     244                            (unless (nx2-var-not-reffed-by-form-p var subform closed) (return)))))
     245                   (if
     246                     (cond ((%ilogbitp operator-acode-subforms-bit op) (setq subforms (%cdr form)))
     247                           ((%ilogbitp operator-acode-list-bit op) (setq subforms (cadr form))))
     248                     (not-reffed-in-formlist subforms)
     249                     (and (or (eq op (%nx1-operator call))
     250                              (eq op (%nx1-operator lexical-function-call)))
     251                          (nx2-var-not-reffed-by-form-p var (cadr form))
     252                          (setq subforms (caddr form))
     253                          (not-reffed-in-formlist (car subforms))
     254                          (not-reffed-in-formlist (cadr subforms)))))))))))
     255
    229256(defun nx2-node-gpr-p (reg)
    230257  (and reg
Note: See TracChangeset for help on using the changeset viewer.