summaryrefslogtreecommitdiffstats
path: root/rand.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-02-05 06:36:11 -0800
committerKaz Kylheku <kaz@kylheku.com>2021-02-05 06:36:11 -0800
commit21c8ee30e7fc4d252698e39c99eeacf31dd5847c (patch)
treea450965689ecb6db87f8a895e53cb561c02b2321 /rand.c
parentb5d486a7ce3f9cfe9a98afe4e5871512068936a9 (diff)
downloadtxr-21c8ee30e7fc4d252698e39c99eeacf31dd5847c.tar.gz
txr-21c8ee30e7fc4d252698e39c99eeacf31dd5847c.tar.bz2
txr-21c8ee30e7fc4d252698e39c99eeacf31dd5847c.zip
compiler: optimize away discard register.
When compiling the procedural special forms prog and prog1, there are subforms whose values are discarded. The compilation of those forms still requires an output register, which is passed down. In certain cases, wasteful moves of data into that register are generated, which we can eliminate. * share/txr/stdlib/compiler.tl (struct compiler): New slot, discards. Holds t-registers that are marked as discard. (compiler alloc-discard-treg): New method. (compiler free-treg): Remove freed treg from discard list. (compiler maybe-alloc-treg): If the given register is a discard, we must allocate. (compiler maybe-mov): New method, replacing maybe-mov function. (compiler comp-if): Replace maybe-mov function calls with method. In the (if test then) case, avoid referencing oreg register after a maybe-mov since it may be a discard such that the maybe-mov produced no code; reference the original register. (comp-progn): Allocate oreg-discard with alloc-discard-treg method instead of alloc-treg. (comp-prog1): Same thing with igreg. (comp-for): For compiling the test expression, use the same output register as what was used for the init block. Do not borrow oreg for this, which may be a discard that will be removed by the maybe-mov. (compiler (comp-setq, comp-ift, comp-switch, comp-block, comp-catch, comp-let, comp-fbind, comp-lambda-impl, comp-or, comp-tree-case, comp-load-time-lit): Replace maybe-mov function calls with method. (maybe-mov): Function removed, replaced by method.
Diffstat (limited to 'rand.c')
0 files changed, 0 insertions, 0 deletions