From b6479c689570ae3df42a45da6d96fc679a5925f3 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 17 Jun 2025 23:49:04 -0700 Subject: compiler: eliminate wasteful treg nulling. * stdlib/optimize.tl (live-info): New slot, clobbered. (basic-block): New slot, cycle. Struct also inherits clobbered slot from live-info. (basic-block print): Print clobbered and cycle. (basic-blocks local-liveness): Calculate clobbered for each instruction and from that for the basic block. (basic-blocks identify-cycle-members): New method. Discovers which basic blocks are part of any cycle, and identifies them by setting the new cycle slot to t. (basic-blocks do-peephole-block): New local functions here for determining whether a register has been clobbered before the first instruction, either in the same basic block or any ancestors. Only works when the block is not part of a cycle. We add a peephole pattern matching move instructions that set tregs to (t 0)/nil. When we are not in a cycle block, and the treg has not previously been clobbered, we know it is clean: it still has the initial nil value set by the VM and we can remove the instruction. * stdlib/compiler.tl (compiler optimize): Call the identify-cycle-members method before peephole. --- stdlib/compiler.tl | 1 + 1 file changed, 1 insertion(+) (limited to 'stdlib/compiler.tl') diff --git a/stdlib/compiler.tl b/stdlib/compiler.tl index fe4db13e..c3043d38 100644 --- a/stdlib/compiler.tl +++ b/stdlib/compiler.tl @@ -1840,6 +1840,7 @@ (while* (and (>= olev 6) (neql nblocks (set nblocks bb.(num-blocks)))) bb.(calc-liveness) + bb.(identify-cycle-members) bb.(peephole) bb.(link-graph) bb.(thread-jumps) -- cgit v1.2.3