summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-09-30 07:59:27 -0700
committerKaz Kylheku <kaz@kylheku.com>2021-09-30 07:59:27 -0700
commit956a7072e76233f33465607c176a3a08ed99811c (patch)
tree47b06a79c7039a7776494b5525b08fb501aedcd0
parenteb3054917a3798cf8201341d84e45d573ebbcff8 (diff)
downloadtxr-956a7072e76233f33465607c176a3a08ed99811c.tar.gz
txr-956a7072e76233f33465607c176a3a08ed99811c.tar.bz2
txr-956a7072e76233f33465607c176a3a08ed99811c.zip
compiler: fix up linkage and recalc liveness in one peephole case.
* stdlib/optimize.tl (basic-blocks peephole-block): Rearrange the code a bit so we don't calculate the xbl, which potentially performs the cut-block, if there is no ybl. We set the bb.recalc flag since we may have cut a block into two and have redirected a jump, and also update the links for that reason.
-rw-r--r--stdlib/optimize.tl19
1 files changed, 11 insertions, 8 deletions
diff --git a/stdlib/optimize.tl b/stdlib/optimize.tl
index 902ca89f..a2717425 100644
--- a/stdlib/optimize.tl
+++ b/stdlib/optimize.tl
@@ -414,16 +414,19 @@
(match-case jinsns
((@jlabel
(end (t @reg)) . @jrest)
- (let* ((xbl (if jrest
- bb.(cut-block jbl jrest jinsns)
- jbl.next))
- (ybl bl.next)
+ (let* ((ybl bl.next)
+ (xbl (if ybl
+ (if jrest
+ bb.(cut-block jbl jrest jinsns)
+ jbl.next)))
(yinsns ybl.insns))
(cond
- ((and xbl ybl)
- (set ybl.insns ^(,ybl.label ,(car insns) ,*(cdr yinsns)))
- (pushnew ybl bb.rescan)
- ^((if (t ,reg) ,xbl.label)))
+ (xbl
+ (set ybl.insns ^(,ybl.label ,(car insns) ,*(cdr yinsns)))
+ (pushnew ybl bb.rescan)
+ (set bb.recalc t)
+ (set bb.links (list ybl xbl))
+ ^((if (t ,reg) ,xbl.label)))
(t insns))))
(@jelse insns))))
(@(require ((if @(as reg (d @dn)) @jlabel) . @nil)