summaryrefslogtreecommitdiffstats
path: root/stdlib/optimize.tl
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2023-07-25 23:40:02 -0700
committerKaz Kylheku <kaz@kylheku.com>2023-07-25 23:40:02 -0700
commit5d8d7480614be7c945e85baac1079fd49e4ca452 (patch)
tree6c747245ba67c3d5730e53214c805859d0a1574b /stdlib/optimize.tl
parent5b662ac8fde7b75dac7100375fa8956f8c72a73e (diff)
downloadtxr-5d8d7480614be7c945e85baac1079fd49e4ca452.tar.gz
txr-5d8d7480614be7c945e85baac1079fd49e4ca452.tar.bz2
txr-5d8d7480614be7c945e85baac1079fd49e4ca452.zip
compiler: compact D registers.
We now have some constant folding in the optimizer too, not just in the front end compiler pass. This is leaving behind dead D registers that are not referenced in the code. Let's compact the D register table to close the gap. * stdlib/compiler.tl (compiler get-dreg): In this function we no longer check that we have allocated too many D registers. We let the counter blow past %lev-size%. Because this creates the fighting chance that the compaction of D regs will reduce their number to %lev-size% or less. By doing this, we allow code to be compilable that otherwise would not be: code that allocates too many D regs which are then optimized away. (compiler compact-dregs): New function. Does all the work. (compiler optimize): Compact the D regs at optimization level 5 or higher. (compile-toplevel): Check for an overflowing D reg count here, after optimization. * stdlib/optimize.tl (basic-blocks null-unused-data): Here, we no longer have to do anything with the D registers.
Diffstat (limited to 'stdlib/optimize.tl')
-rw-r--r--stdlib/optimize.tl6
1 files changed, 1 insertions, 5 deletions
diff --git a/stdlib/optimize.tl b/stdlib/optimize.tl
index ee9257ac..49a8259e 100644
--- a/stdlib/optimize.tl
+++ b/stdlib/optimize.tl
@@ -798,16 +798,12 @@
cl.(apply-treg-compacting-map map))))))
(defmeth basic-blocks null-unused-data (bb)
- (let ((used-dregs 0)
- (used-funs 0)
+ (let ((used-funs 0)
(co bb.compiler))
(each ((bl bb.list))
(each ((insn bl.insns))
- (if-match @(coll (d @dn)) insn
- (set-mask used-dregs (mask . dn)))
(if-match (@(or gcall gapply getf getlx setlx) @nil @fn . @nil) insn
(set-mask used-funs (mask fn)))))
- co.(null-dregs used-dregs)
co.(null-stab used-funs)))
(defun rewrite (fun list)