diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-09-28 06:54:37 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-09-28 06:54:37 -0700 |
commit | 21bd7298ac8110322db108f2c8be78adbb43b6b1 (patch) | |
tree | f696ea96c8bbdcf53b0d3796a139c1bc31da8364 /stdlib | |
parent | a06fdec52c8d436db925ec158d231627773f5bf9 (diff) | |
download | txr-21bd7298ac8110322db108f2c8be78adbb43b6b1.tar.gz txr-21bd7298ac8110322db108f2c8be78adbb43b6b1.tar.bz2 txr-21bd7298ac8110322db108f2c8be78adbb43b6b1.zip |
compiler: code clean-up in peephole optimizer.
* stdlib/optimize.tl (basic-blocks peephole-block): When we match a
branching instruction, including jend, we know that's the end of the
basic block. So there is no need to splice the (rest insns) into
the output; let's get rid of that. On the other hand, there is also no
need to have a specific pattern match for the end of the list such
as ((jmp @label)). This costs extra cycles to validate. Let's
consistently match these basic-block terminating instructions using
prefix patterns like ((jmp @label) . @nil)).
Diffstat (limited to 'stdlib')
-rw-r--r-- | stdlib/optimize.tl | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/stdlib/optimize.tl b/stdlib/optimize.tl index 8d2c1f5c..f6acad64 100644 --- a/stdlib/optimize.tl +++ b/stdlib/optimize.tl @@ -378,7 +378,7 @@ (pushnew bl bb.rescan) (set bb.recalc t bb.reelim t) - ^((jmp ,jlabel) ,*(cdr insns))) + ^((jmp ,jlabel))) (@(require ((@(or gcall gapply) (t @n) @idx . @nil) . @nil) (dead-treg (car insns) n) [%effect-free% [bb.symvec idx]]) @@ -414,7 +414,7 @@ . @rest) ^(,(cadr insns) ,(car insns) ,*rest)) (((@(or frame dframe) . @nil) - (if (t @reg) @jlabel)) + (if (t @reg) @jlabel) . @nil) (let ((jinsns [bb.hash jlabel].insns)) (match-case jinsns ((@jlabel @@ -437,13 +437,13 @@ (@(require ((ifq @(as reg (d @dn)) (t 0) @jlabel) . @nil) (not (memqual reg bb.lt-dregs))) ^((jmp ,jlabel))) - (((jmp @jlabel) . @rest) + (((jmp @jlabel) . @nil) (let* ((jinsns (cdr [bb.hash jlabel].insns)) (oinsns (match-case jinsns (((jend @nil) . @nil) - ^(,(car jinsns) ,*rest)) + ^(,(car jinsns))) ((@nil (jend @nil) . @nil) - ^(,(car jinsns) ,(cadr jinsns) ,*rest)) + ^(,(car jinsns) ,(cadr jinsns))) (@else insns)))) (when (neq insns oinsns) (pushnew bl bb.rescan) |