summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-03-02 07:11:48 -0800
committerKaz Kylheku <kaz@kylheku.com>2021-03-02 07:11:48 -0800
commit588db65599c0588905fa38923d01488e9ba9feec (patch)
treee33e3955d0700defc532fb8510795746429460b1
parenta3a7bf1bbf24a63ca18a054e77a8d8bc4b1a77c0 (diff)
downloadtxr-588db65599c0588905fa38923d01488e9ba9feec.tar.gz
txr-588db65599c0588905fa38923d01488e9ba9feec.tar.bz2
txr-588db65599c0588905fa38923d01488e9ba9feec.zip
compiler: reorder optimization passes.
* share/txr/stdlib/compiler.tl (compiler optimize): Perform the control flow optimizations of jump threading and dead code elimination first. Then, do the data-flow-assisted optimizations on the re-calculated control flow graph. With this, two more useless insructions are shaved off the pattern matching Ackermann: (defun ack (:match) ((0 @n) (+ n 1)) ((@m 0) (ack (- m 1) 1)) ((@m @n) (ack (- m 1) (ack m (- n 1))))) It now compiles down to 16 instructions instead of 18; and the speedup of (ack 3 7) versus interpreted goes from 36.0 to 37.3 times. The reason that the new reduction in the code is possible is that previously, the code being analyzed was in separate basic blocks, which are now merged together in the dead code elimination pass. * share/txr/stdlib/compiler.tl (compiler optimize): Move calc-liveness and peephole after elim-dead-code.
-rw-r--r--share/txr/stdlib/compiler.tl4
1 files changed, 2 insertions, 2 deletions
diff --git a/share/txr/stdlib/compiler.tl b/share/txr/stdlib/compiler.tl
index 59050ff5..6b1c1a17 100644
--- a/share/txr/stdlib/compiler.tl
+++ b/share/txr/stdlib/compiler.tl
@@ -1504,10 +1504,10 @@
(defmeth compiler optimize (me insns)
(let* ((lt-dregs (mapcar .oreg me.lt-frags))
(bb (new (basic-blocks insns lt-dregs))))
- bb.(calc-liveness)
- bb.(peephole)
bb.(thread-jumps)
bb.(elim-dead-code)
+ bb.(calc-liveness)
+ bb.(peephole)
bb.(get-insns)))
(defun true-const-p (arg)