From ebee14dd08689090e7ba1b7445318d526ae78d40 Mon Sep 17 00:00:00 2001 From: Vincent St-Amour Date: Mon, 29 Jun 2009 19:50:35 -0400 Subject: [PATCH] Optimized register allocation by moving a costly calculation outside of an inner loop. Instead of taking ~30 seconds, it now takes ~3. --- register-allocation.scm | 6 +++--- six-comp.scm | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/register-allocation.scm b/register-allocation.scm index e52dc66..3d202fc 100644 --- a/register-allocation.scm +++ b/register-allocation.scm @@ -269,12 +269,12 @@ (table-set! reverse-register-table (byte-cell-name cell) ;; TODO add the bb ? adr)))) - (let ((neighbours (byte-cell-interferes-with byte-cell))) + (let ((neighbours (set->list (byte-cell-interferes-with byte-cell)))) (let loop1 ((adr 0)) (if (and memory-divide ; the user wants his own zone (>= adr memory-divide)) ; and we'd use it (error "register allocation would cross the memory divide") ;; TODO fallback ? - (let loop2 ((lst (set->list neighbours))) ;; TODO keep using sets, but not urgent, it's not a bottleneck + (let loop2 ((lst neighbours)) ;; TODO keep using sets, but not urgent, it's not a bottleneck (if (null? lst) (begin (byte-cell-adr-set! byte-cell adr) (set-register-table byte-cell adr) @@ -310,5 +310,5 @@ (color byte-cell))))) (pp register-allocation:) - (time (alloc-reg all-live)) ;; TODO convert find-min-neighbours and alloc-reg to use tables, not urgent since it's not a bottleneck + (time (alloc-reg all-live)) (display (string-append (number->string (+ max-adr 1)) " RAM bytes\n")))) diff --git a/six-comp.scm b/six-comp.scm index 30cf9af..81269ae 100755 --- a/six-comp.scm +++ b/six-comp.scm @@ -7,7 +7,7 @@ (define coalesce? #t) ;; to use when interpreting -(begin (include "asm.scm") +'(begin (include "asm.scm") (include "pic18.scm") (include "pic18-sim.scm") (include "utilities.scm") @@ -21,7 +21,7 @@ (include "register-allocation.scm") (include "profiler.scm")) ;; to use with compiled code -'(begin (load "asm") +(begin (load "asm") (load "pic18") (load "pic18-sim") (load "utilities") -- 2.11.4.GIT