From 03d79d37bfbaccddbf7c83d25770a35fda95dad7 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 6 Apr 2023 22:38:59 -0700 Subject: compiler: small local refactoring in optimizer. * stdlib/optimize.tl (basic-blocks peephole-block): Move local rename function into main labels block, so other optimizations will be able to use it. Remove an unused argument, and change the recursion to a mapcar, since that's what it's doing. --- stdlib/optimize.tl | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'stdlib') diff --git a/stdlib/optimize.tl b/stdlib/optimize.tl index 99b59210..8ab9e7ca 100644 --- a/stdlib/optimize.tl +++ b/stdlib/optimize.tl @@ -357,7 +357,9 @@ (and li (not (bit li.used n))))) (only-locally-used-treg (insn n) (let ((li [bb.li-hash insn])) - (and li (bit li.used n) (not (bit bl.live n)))))) + (and li (bit li.used n) (not (bit bl.live n))))) + (rename (insns dst src) + (mapcar (op subst-preserve dst src bb [bb.li-hash @1] @1) insns))) (rewrite-case insns code ;; dead t-reg (@(require ((@(or mov getlx getv getf getfb) (t @n) . @nil) . @nil) @@ -387,13 +389,7 @@ (not (find src rest : [chain bb.li-hash .def]))) (pushnew bl bb.rescan) (set bb.recalc t) - (labels ((rename (insns n dst src) - (tree-case insns - ((fi . t) - (cons (subst-preserve dst src bb [bb.li-hash fi] fi) - (rename (cdr insns) n dst src))) - (else else)))) - (rename (cdr insns) n dst src))) + (rename rest dst src)) ;; wasteful moves (((mov @reg0 @nil) (mov @reg0 @nil) . @nil) (cdr insns)) -- cgit v1.2.3