From cf126a147c108497ef8a387dc869a4c24a9622ed Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 3 Mar 2021 21:10:14 -0800 Subject: compiler: another late-peephole pattern. * share/txr/stdlib/optimize.tl (late-peephole): Add a 6-instruction pattern which is seen in pattern-matching code in optimize.tlo and compiler.tlo. This can be tidied up a little bit, reducing the instructions to 5, eliminating redundant comparisons and threading a jump. At this point we are probably working too hard for too little gain. More effort in other areas like common subexpression elimination could produce bigger wins. --- share/txr/stdlib/optimize.tl | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/share/txr/stdlib/optimize.tl b/share/txr/stdlib/optimize.tl index 1541cd17..df423f2f 100644 --- a/share/txr/stdlib/optimize.tl +++ b/share/txr/stdlib/optimize.tl @@ -504,6 +504,27 @@ ^((ifq ,reg (t 0) ,lab3) ,lab1 ,*rest)))) + (((mov (t @tn) (d @dn)) + (jmp @lab3) + @lab1 + (mov (t @tn) (t 0)) + (jmp @lab3) + @lab2 + (mov (t @tn) (t 0)) + @(symbolp @lab3) + (ifq (t @tn) (t 0) @lab4) + . @rest) + (let ((lab5 (gensym "nl"))) + ^((mov (t ,tn) (d ,dn)) + (jmp ,lab4) + ,lab1 + ,lab2 + (mov (t ,tn) (t 0)) + (jmp ,lab5) + ,lab3 + (ifq (t ,tn) (t 0) ,lab4) + ,lab5 + ,*rest))) (@else else))) (defun rewrite (fun list) -- cgit v1.2.3