diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2023-04-16 23:30:27 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2023-04-16 23:30:27 -0700 |
commit | 3508483456416a42f26bffec9c02cdad47e18765 (patch) | |
tree | 16c06cadb1f639ea376d37b42b84ca17acf3e4c2 /stdlib | |
parent | d85da8e7696cda9e6bd441c13371dcad5753785d (diff) | |
download | txr-3508483456416a42f26bffec9c02cdad47e18765.tar.gz txr-3508483456416a42f26bffec9c02cdad47e18765.tar.bz2 txr-3508483456416a42f26bffec9c02cdad47e18765.zip |
compiler: allow v reg source in t-reg optimization
This change is now possible due to the previous bugfix.
* stdlib/optimize.tl (basic-blocks rename): If
the source register is a v-reg, do not allow
the propagation past an end instruction. This
is a precaution because the end instruction
could be the end of the frame in which the
v-register is valid; we don't want to propagate
it outside of that frame.
Diffstat (limited to 'stdlib')
-rw-r--r-- | stdlib/optimize.tl | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/stdlib/optimize.tl b/stdlib/optimize.tl index 089b1334..bb1b84c3 100644 --- a/stdlib/optimize.tl +++ b/stdlib/optimize.tl @@ -362,17 +362,20 @@ (defmeth basic-blocks rename (bb insns dst src) (build - (whilet ((insn (pop insns))) - (let ((close (if-match (close . @nil) insn t)) - (li [bb.li-hash insn])) - (cond - (close (add insn)) - ((or (mequal li.def0 dst src) - (mequal li.def1 dst src)) - (add insn) - (pend insns) - (set insns nil)) - (t (add (subst-preserve dst src bb li insn)))))))) + (let ((vreg (eq (car src) 'v))) + (whilet ((insn (pop insns))) + (let ((end (if-match (end . @nil) insn t)) + (close (if-match (close . @nil) insn t)) + (li [bb.li-hash insn])) + (cond + (close (add insn)) + ((or (and vreg end) + (mequal li.def0 dst src) + (mequal li.def1 dst src)) + (add insn) + (pend insns) + (set insns nil)) + (t (add (subst-preserve dst src bb li insn))))))))) (defmeth basic-blocks peephole-block (bb bl) (let ((code bb.(do-peephole-block bl bl.insns))) @@ -407,8 +410,7 @@ ;; unnecessary copying t-reg (@(require ((mov @(as dst (t @n)) @src) . @rest) (only-locally-used-treg (car insns) n) - (nequal dst src) - (neq (car src) 'v)) + (nequal dst src)) (let ((ren bb.(rename rest dst src))) (cond ((nequal rest ren) |