diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2019-08-28 21:03:28 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2019-08-28 21:03:28 -0700 |
commit | 0689ed6d0d0d74f9ca62057290db3bda8622afba (patch) | |
tree | 0d06d294c09433d61917e521df93b7d7ad716092 /share | |
parent | 872b311ba9b24ed244bb37795ecaae96082cbe85 (diff) | |
download | txr-0689ed6d0d0d74f9ca62057290db3bda8622afba.tar.gz txr-0689ed6d0d0d74f9ca62057290db3bda8622afba.tar.bz2 txr-0689ed6d0d0d74f9ca62057290db3bda8622afba.zip |
compiler: elide nil var intializaton.
Virtual machine local variables registers don't require
nil initialization. In cases when a complex variable
initializer is known to return nil, we can elide the move
instrution which moves that nil into the register.
* share/txr/stdlib/compiler.tl (null-reg): New function.
(compiler comp-let): Don't move the value of the output
register of the init fragment into the variable, if that
register is the null register t0.
Diffstat (limited to 'share')
-rw-r--r-- | share/txr/stdlib/compiler.tl | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/share/txr/stdlib/compiler.tl b/share/txr/stdlib/compiler.tl index 5553f293..60411e39 100644 --- a/share/txr/stdlib/compiler.tl +++ b/share/txr/stdlib/compiler.tl @@ -206,6 +206,9 @@ (or [*dedup* obj] (set [*dedup* obj] obj))) (t obj))) +(defun null-reg (reg) + (equal reg '(t 0))) + (defmeth compiler get-dreg (me obj) (let ((dobj (dedup obj))) (condlet @@ -748,8 +751,9 @@ (frag me.(compile bind.loc fenv form))) (when seq fenv.(rename-var tmp sym)) - (pend frag.code - (maybe-mov bind.loc frag.oreg)) + (pend frag.code) + (unless (null-reg frag.oreg) + (pend (maybe-mov bind.loc frag.oreg))) (set ffuns (uni ffuns frag.ffuns) fvars (uni fvars (if seq |