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
commitcdeb5bfa8b2fae5cfd8d427d347fbe9195e2d115 (patch)
treee33e3955d0700defc532fb8510795746429460b1
parent82c19e330fef2a9ef4055923fdbb9cd6764043b3 (diff)
downloadtxr-cdeb5bfa8b2fae5cfd8d427d347fbe9195e2d115.tar.gz
txr-cdeb5bfa8b2fae5cfd8d427d347fbe9195e2d115.tar.bz2
txr-cdeb5bfa8b2fae5cfd8d427d347fbe9195e2d115.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)