summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-11-26 20:11:58 -0800
committerKaz Kylheku <kaz@kylheku.com>2021-11-26 20:11:58 -0800
commitbeac7fcc9cf4c7533d658e7c4839b715d6c714cd (patch)
tree0562347684bee87860382450767aa0b9a1eec3f7
parent6afada2bbf58ed9ba6a8701bb7ec56633cb2633e (diff)
downloadtxr-beac7fcc9cf4c7533d658e7c4839b715d6c714cd.tar.gz
txr-beac7fcc9cf4c7533d658e7c4839b715d6c714cd.tar.bz2
txr-beac7fcc9cf4c7533d658e7c4839b715d6c714cd.zip
compiler: replace late-peephole pattern with real approach.
* stdlib/optimize.tl (basic-blocks merge-jump-thunks): For each group of candidate jump-blocks, search the entire basic block list for one more jump block which is identical to the others, except that it doesn't end in a jmp, but rather falls through to the same target that the group jumps to. That block is then included in the group, and also becomes the default leader since it is pushed to the front. (basic-blocks late-peephole): Remove the peephole pattern which tried to attack the same problem. The new approach is much more effective: when compiling stdlib, 77 instances occur in which such a block is identified and added! The peephole pattern only matched six times.
-rw-r--r--stdlib/optimize.tl20
1 files changed, 8 insertions, 12 deletions
diff --git a/stdlib/optimize.tl b/stdlib/optimize.tl
index 57eca186..2274e424 100644
--- a/stdlib/optimize.tl
+++ b/stdlib/optimize.tl
@@ -564,6 +564,14 @@
bb.list))
(hash (group-by [chain .insns cdr] candidates)))
(dohash (insns bls hash)
+ (let ((link (car (car bls).links)))
+ (each ((bb bb.list))
+ (if (and (not (member bb bls))
+ (null (cdr bb.links))
+ (eq bb.next link)
+ (starts-with (cdr bb.insns) insns)
+ (eql (len bb.insns) (len insns)))
+ (push bb bls))))
(when (cdr bls)
(whenlet ((keep (or (keep-if (op some @1.rlinks (op eq @@1) .next) bls)
(list (car bls))))
@@ -625,18 +633,6 @@
,lab2
(end (t ,ty))
,*rest))
- ((@(symbolp @lab1)
- @(consp @insn)
- (jmp @lab3)
- @(symbolp @lab2)
- @insn
- @(symbolp @lab3)
- . @rest)
- ^(,lab1
- ,lab2
- ,insn
- ,lab3
- ,*rest))
(@else else)))
(defun rewrite (fun list)