summaryrefslogtreecommitdiffstats
path: root/stdlib/optimize.tl
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/optimize.tl')
-rw-r--r--stdlib/optimize.tl15
1 files changed, 15 insertions, 0 deletions
diff --git a/stdlib/optimize.tl b/stdlib/optimize.tl
index 5002b1fd..1d423f3c 100644
--- a/stdlib/optimize.tl
+++ b/stdlib/optimize.tl
@@ -539,6 +539,21 @@
(val (apply fun args))
(dreg co.(get-dreg val)))
^((mov ,tgt ,dreg) ,*rest)))
+ ;; apply to gapply
+ (@(require @(with ((getf @(as treg (t @tn)) @idx) . @rest)
+ @(scan @(or @(with @(as apl ((apply @dest @treg . @args)
+ . @arest))
+ li [bb.li-hash (car apl)])
+ @(require (@insn . @nil)
+ (find treg insn))))
+ rest)
+ apl
+ (or (equal dest treg)
+ (not (bit li.used tn))))
+ (set bb.recalc t)
+ (let* ((gapl ^(gapply ,dest ,idx ,*args)))
+ (set [bb.li-hash gapl] li)
+ ^(,*(ldiff rest apl) ,gapl ,*arest)))
(@nil insns))))
(defmeth basic-blocks peephole (bb)