diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-09-30 07:59:27 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-09-30 07:59:27 -0700 |
commit | 904448c676063cba97e61f8205798e5ad234b7a7 (patch) | |
tree | 47b06a79c7039a7776494b5525b08fb501aedcd0 | |
parent | 50cf89db68ceb26f4e2a588eecb7a5575d24bb1c (diff) | |
download | txr-904448c676063cba97e61f8205798e5ad234b7a7.tar.gz txr-904448c676063cba97e61f8205798e5ad234b7a7.tar.bz2 txr-904448c676063cba97e61f8205798e5ad234b7a7.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.tl | 19 |
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) |