From 5df176fd3bd56968a9ca56bc03609650c0c5794d Mon Sep 17 00:00:00 2001 From: Peter Bex Date: Sun, 28 Feb 2016 18:13:21 +0100 Subject: [PATCH] Fix excessive temporary generation. In deeply nested if structures, we would generate a set of temporaries for each arm of the if, while the code would re-use temporaries. This means if each arm uses N temporaries, at a nesting depth of M we would generate N*2^M temporaries, instead of just N. This is especially clear in the generated code for compiler.scm; there is one C function with over 200 temporaries which uses less than 100! --- compiler.scm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/compiler.scm b/compiler.scm index 764c5f0..c91e21c 100644 --- a/compiler.scm +++ b/compiler.scm @@ -2775,11 +2775,14 @@ ((if ##core#cond) (let* ((test (walk (first subs) e e-count here boxes)) + (t0 temporaries) (a0 allocated) (x1 (walk (second subs) e e-count here boxes)) + (t1 temporaries) (a1 allocated) (x2 (walk (third subs) e e-count here boxes))) (set! allocated (+ a0 (max (- allocated a1) (- a1 a0)))) + (set! temporaries (+ t0 (max (- temporaries t1) (- t1 t0)))) (make-node class params (list test x1 x2)))) ((##core#switch) -- 2.1.4