diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-01-26 20:30:52 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-01-26 20:30:52 -0800 |
commit | 6922eb95ca160c9eac971e2cb2a608dc82c1a3df (patch) | |
tree | e31f7ed4d04eb1ebefb8331b07694cc588a0b81b | |
parent | 0441727291e0785ea43db24312fbacf330a24834 (diff) | |
download | txr-6922eb95ca160c9eac971e2cb2a608dc82c1a3df.tar.gz txr-6922eb95ca160c9eac971e2cb2a608dc82c1a3df.tar.bz2 txr-6922eb95ca160c9eac971e2cb2a608dc82c1a3df.zip |
optimizer: thread close instructions.
* share/txr/stdlib/optimize.tl (basic-blocks thread-jumps):
Also thread the implicit branch performed by close
instructions. If a close instruction branches to an
unconditional jump, then rewrite the close to jump that jump's
target.
-rw-r--r-- | share/txr/stdlib/optimize.tl | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/share/txr/stdlib/optimize.tl b/share/txr/stdlib/optimize.tl index 9cb6ab85..78fab4b2 100644 --- a/share/txr/stdlib/optimize.tl +++ b/share/txr/stdlib/optimize.tl @@ -69,6 +69,12 @@ ((@(op eq jlabel) (jmp @(require @jjlabel (neq jjlabel jlabel))) . @nil) ^((ifq ,reg ,creg ,jjlabel) ,*rest)) (@jelse insns)))) + (((close @reg @nargs @jlabel . @cargs) . @rest) + (let ((jinsns [bb.hash jlabel])) + (match-case jinsns + ((@(op eq jlabel) (jmp @(require @jjlabel (neq jjlabel jlabel))) . @nil) + ^((close ,reg ,nargs ,jjlabel ,*cargs) ,*rest)) + (@jelse insns)))) (@else insns))) code)))) |