From da9537ed0bc95c46e49a133daf97997eabc0ecf3 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 26 Jan 2021 20:30:52 -0800 Subject: 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. --- share/txr/stdlib/optimize.tl | 6 ++++++ 1 file changed, 6 insertions(+) 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)))) -- cgit v1.2.3