summaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-03-03 21:10:14 -0800
committerKaz Kylheku <kaz@kylheku.com>2021-03-03 21:10:14 -0800
commitcf126a147c108497ef8a387dc869a4c24a9622ed (patch)
tree43bc6fb625be489254b9b06862bf3d0c1afdf66e /share
parentd6b6dfcf6b8adcb6c2fbc453c2c0fcbf3a27cbc3 (diff)
downloadtxr-cf126a147c108497ef8a387dc869a4c24a9622ed.tar.gz
txr-cf126a147c108497ef8a387dc869a4c24a9622ed.tar.bz2
txr-cf126a147c108497ef8a387dc869a4c24a9622ed.zip
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.
Diffstat (limited to 'share')
-rw-r--r--share/txr/stdlib/optimize.tl21
1 files changed, 21 insertions, 0 deletions
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)