diff options
Diffstat (limited to 'stdlib/optimize.tl')
-rw-r--r-- | stdlib/optimize.tl | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/stdlib/optimize.tl b/stdlib/optimize.tl index 1d423f3c..29fe0a64 100644 --- a/stdlib/optimize.tl +++ b/stdlib/optimize.tl @@ -528,15 +528,18 @@ (cons (car insns) ren)) (t insns)))) ;; constant folding - (@(require ((gcall @tgt @idx . @(all @(or (d @dn) - @(with (t 0) dn nil)))) + (@(require ((@(as op @(or gapply 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 [iffi true dvec] dn)) - (val (apply fun args)) + (val (if (eq op 'gcall) + (apply fun args) + (apply fun (append [args 0..-1] [args -1])))) (dreg co.(get-dreg val))) ^((mov ,tgt ,dreg) ,*rest))) ;; apply to gapply |