summaryrefslogtreecommitdiffstats
path: root/stdlib/optimize.tl
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2023-07-15 20:09:36 -0700
committerKaz Kylheku <kaz@kylheku.com>2023-07-15 20:09:36 -0700
commit1c9560b9388d64b2cdb66c90790d61b738cdf84c (patch)
treef2ad341c0eae01e2b48683d20e039da7b92b4a6b /stdlib/optimize.tl
parentf0874f294b1d70e9e4a9ac79a16788f286755c40 (diff)
downloadtxr-1c9560b9388d64b2cdb66c90790d61b738cdf84c.tar.gz
txr-1c9560b9388d64b2cdb66c90790d61b738cdf84c.tar.bz2
txr-1c9560b9388d64b2cdb66c90790d61b738cdf84c.zip
compiler: recognize T0 register (nil) as constant.
* stdlib/optimize.tl (basic-blocks do-peephole-block): The constant folding case should fire even if some of the arguments of the call aren't D registers but T0.
Diffstat (limited to 'stdlib/optimize.tl')
-rw-r--r--stdlib/optimize.tl6
1 files changed, 4 insertions, 2 deletions
diff --git a/stdlib/optimize.tl b/stdlib/optimize.tl
index 6ba0685e..5002b1fd 100644
--- a/stdlib/optimize.tl
+++ b/stdlib/optimize.tl
@@ -528,12 +528,14 @@
(cons (car insns) ren))
(t insns))))
;; constant folding
- (@(require ((gcall @tgt @idx . @(all (d @dn))) . @rest)
+ (@(require ((gcall @tgt @idx . @(all @(or (d @dn)
+ @(with (t 0) dn nil))))
+ . @rest)
[%const-foldable% [bb.symvec idx]])
(let* ((co bb.compiler)
(dvec co.(get-datavec))
(fun [bb.symvec idx])
- (args [mapcar dvec dn])
+ (args (mapcar [iffi true dvec] dn))
(val (apply fun args))
(dreg co.(get-dreg val)))
^((mov ,tgt ,dreg) ,*rest)))