diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-09-30 07:43:04 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-09-30 07:43:04 -0700 |
commit | eb3054917a3798cf8201341d84e45d573ebbcff8 (patch) | |
tree | a79421215eedb01db17aca1e6cfbc053f1c5729b /stdlib/optimize.tl | |
parent | cc37c787f80e57e43176af3b0abf952721917c19 (diff) | |
download | txr-eb3054917a3798cf8201341d84e45d573ebbcff8.tar.gz txr-eb3054917a3798cf8201341d84e45d573ebbcff8.tar.bz2 txr-eb3054917a3798cf8201341d84e45d573ebbcff8.zip |
compiler: eliminate some redundant hash lookups.
* stdlib/optimize.tl (basic-blocks thread-jumps-block,
basic-blocks peephole-block): Streamline various cases of [bb.hash
jlabel] being wastefully called twice to look up the same block
referenced by the same label.
Diffstat (limited to 'stdlib/optimize.tl')
-rw-r--r-- | stdlib/optimize.tl | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/stdlib/optimize.tl b/stdlib/optimize.tl index 2bbd9f27..902ca89f 100644 --- a/stdlib/optimize.tl +++ b/stdlib/optimize.tl @@ -295,8 +295,8 @@ ^(jmp ,jjlabel)) (@jelse insn)))) ((if @reg @jlabel) - (let ((jinsns [bb.hash jlabel].insns)) - (match-case jinsns + (let* ((jbl [bb.hash jlabel])) + (match-case jbl.insns ((@jlabel (if @reg @(and @jjlabel @(not @jlabel))) . @nil) @@ -306,14 +306,14 @@ ^(if ,reg ,jjlabel)) ((@jlabel (ifq @reg (t 0) @jjlabel) . @nil) - (let ((xbl [bb.hash jlabel].next)) + (let ((xbl jbl.next)) (if xbl ^(if ,reg ,xbl.label) insn))) (@jelse insn)))) ((ifq @reg @creg @jlabel) - (let ((jinsns [bb.hash jlabel].insns)) - (match-case jinsns + (let ((jbl [bb.hash jlabel])) + (match-case jbl.insns ((@jlabel (ifq @reg @creg @(and @jjlabel @(not @jlabel))) . @nil) @@ -321,7 +321,7 @@ ((@(require @jlabel (equal creg '(t 0))) (if @reg @(and @jjlabel @(not @jlabel))) . @nil) - (let ((xbl [bb.hash jlabel].next)) + (let ((xbl jbl.next)) (if xbl ^(ifq ,reg ,creg ,xbl.label) insn))) @@ -330,8 +330,8 @@ ^(ifq ,reg ,creg ,jjlabel)) (@jelse insn)))) ((close @reg @frsize @ntregs @jlabel . @cargs) - (let ((jinsns [bb.hash jlabel].insns)) - (match-case jinsns + (let ((jbl [bb.hash jlabel])) + (match-case jbl.insns ((@jlabel (jmp @(and @jjlabel @(not @jlabel))) . @nil) ^(close ,reg ,frsize ,ntregs ,jjlabel ,*cargs)) @@ -409,13 +409,14 @@ ^(,(cadr insns) ,(car insns) ,*rest)) (((@(or frame dframe) . @nil) (if (t @reg) @jlabel) . @nil) - (let ((jinsns [bb.hash jlabel].insns)) + (let* ((jbl [bb.hash jlabel]) + (jinsns jbl.insns)) (match-case jinsns ((@jlabel (end (t @reg)) . @jrest) (let* ((xbl (if jrest - bb.(cut-block [bb.hash jlabel] jrest jinsns) - [bb.hash jlabel].next)) + bb.(cut-block jbl jrest jinsns) + jbl.next)) (ybl bl.next) (yinsns ybl.insns)) (cond |