summaryrefslogtreecommitdiffstats
path: root/stdlib
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-09-29 22:46:01 -0700
committerKaz Kylheku <kaz@kylheku.com>2021-09-29 22:46:01 -0700
commit68f856fc1fe2f662e3771bec32fb447304c56818 (patch)
tree010d45e223c62a54568f01392da7ef7042d7d7c8 /stdlib
parentb9398943c06b8d0503f71eda56c59dcd36e826e2 (diff)
downloadtxr-68f856fc1fe2f662e3771bec32fb447304c56818.tar.gz
txr-68f856fc1fe2f662e3771bec32fb447304c56818.tar.bz2
txr-68f856fc1fe2f662e3771bec32fb447304c56818.zip
compiler: remove impossible cases in jump threading.
* stdlib/optimize.tl (basic-blocks thread-jumps-block): There can't be any instructions in a basic block after an if or ifq, so in these cases, jrest is always nil. Let's ignore that nil efficiently with @nil, and get rid of the cut-block branches of the code. There is a similar case in peephole-block, but the target of the jump is an (end ...) which doesn't necessarily end a basic block. I temporarily put in an (assert (null jrest)), and, surprisingly, it never went off during a rebuild of the library or running of the test case. Still, only a jend ends a basic block; it would not be correct to simplify it like these two cases in thread-jumps-block.
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/optimize.tl12
1 files changed, 4 insertions, 8 deletions
diff --git a/stdlib/optimize.tl b/stdlib/optimize.tl
index db069efa..5f81bc10 100644
--- a/stdlib/optimize.tl
+++ b/stdlib/optimize.tl
@@ -309,10 +309,8 @@
(jmp @(and @jjlabel @(not @jlabel))) . @nil)
^(if ,reg ,jjlabel))
((@jlabel
- (ifq @reg (t 0) @jjlabel) . @jrest)
- (let ((xbl (if jrest
- bb.(cut-block [bb.hash jlabel] jrest jinsns)
- bb.(next-block [bb.hash jlabel]))))
+ (ifq @reg (t 0) @jjlabel) . @nil)
+ (let ((xbl bb.(next-block [bb.hash jlabel])))
(if xbl
^(if ,reg ,xbl.label)
insn)))
@@ -326,10 +324,8 @@
^(ifq ,reg ,creg ,jjlabel))
((@(require @jlabel (equal creg '(t 0)))
(if @reg
- @(and @jjlabel @(not @jlabel))) . @jrest)
- (let ((xbl (if jrest
- bb.(cut-block [bb.hash jlabel] jrest jinsns)
- bb.(next-block [bb.hash jlabel]))))
+ @(and @jjlabel @(not @jlabel))) . @nil)
+ (let ((xbl bb.(next-block [bb.hash jlabel])))
(if xbl
^(ifq ,reg ,creg ,xbl.label)
insn)))