diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-09-29 21:28:13 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-09-29 21:28:13 -0700 |
commit | b9398943c06b8d0503f71eda56c59dcd36e826e2 (patch) | |
tree | 64c3bb7b60e0da1e5f8867739c865007054b1bcd /linenoise/LICENSE | |
parent | 21bd7298ac8110322db108f2c8be78adbb43b6b1 (diff) | |
download | txr-b9398943c06b8d0503f71eda56c59dcd36e826e2.tar.gz txr-b9398943c06b8d0503f71eda56c59dcd36e826e2.tar.bz2 txr-b9398943c06b8d0503f71eda56c59dcd36e826e2.zip |
compiler: peephole: merge basic blocks when jmp removed.
When a jmp instruction is removed from (necessarily) the end of a basic
block, that basic block can be merged with the next one, and marked for
re-scanning.
A test case where this eliminates wasteful register-register move
instruction is (match #(@a) #(3) a).
* stdlib/optimize.tl (basic-blocks): New slot, tryjoin.
(basic-blocks join-block): Null out the instruction list of the joined
block. This helps if we do this during peephole processing, because it
happens in the middle of an iteration over a list of blocks which can
still visit the next block that has been merged into its predecesor; we
don't want to be processing instructions that are no longer relevant.
(basic-blocks peephole-block): In the one case where a conditional
instruction is deleted from the end of the basic block, we add the block
to the rescan list, and also to the tryjoin list. If the block can
be merged with the next one, that can create more opportunities for
peephole optimization.
(basic-blocks peephole): Use zap in a few places to condense the logic
of sampling a state variable that needs to be nulled out. Add the
processing of the tryjoin list: pop basic blocks from the list, and try
to merge them with their successor, if possible. We handle cases here
where the next block could itself be in tryjoin. Also, if we join any
blocks, we set the recalc flag to recalculate the liveness info.
Diffstat (limited to 'linenoise/LICENSE')
0 files changed, 0 insertions, 0 deletions