From e043811980db560fc2507bb53b644e54c80527dc Mon Sep 17 00:00:00 2001 From: lemon Date: Mon, 8 Sep 2025 22:05:33 +0200 Subject: regalloc: start implementing linear scan --- optmem.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'optmem.c') diff --git a/optmem.c b/optmem.c index d733a70..00be3a0 100644 --- a/optmem.c +++ b/optmem.c @@ -19,7 +19,7 @@ static const uchar load2ext[] = { #define load2ext(o) (load2ext[(o) - Oloads1]) #define storesz(o) (1 << ((o) - Ostore1)) -/* Implements algorithm in 'Simple and Efficient Construction of Static Single' (Braun et al) */ +/* Implements algorithm in 'Simple and Efficient Construction of Static Single Assignment' (Braun et al) */ struct pendingphi { ushort var, phi; }; struct ssabuilder { @@ -43,6 +43,9 @@ deltrivialphis(struct ssabuilder *sb, struct block *blk, union ref phiref) assert(instrtab[phiref.i].op == Ophi); + if (phiref.i == 4) + efmt(""); + for (int i = 0; i < blk->npred; ++i) { if (args[i].bits == same.bits || args[i].bits == phiref.bits) continue; /* unique value or self-reference */ @@ -79,6 +82,7 @@ Redo: } } } + deluses(phiref.i); return same; } @@ -185,7 +189,6 @@ mem2reg(struct function *fn) } do { - for (int i = 0; i < blk->ins.n; ++i) { struct use *use, *uend; enum irclass k = 0; -- cgit v1.2.3