~mpu/qbe

Eliminate fully overlapping blits after coalescing stack slots v1 PROPOSED

Richard McCormack: 1
 Eliminate fully overlapping blits after coalescing stack slots

 1 files changed, 9 insertions(+), 4 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~mpu/qbe/patches/50611/mbox | git am -3
Learn more about email & git

[PATCH] Eliminate fully overlapping blits after coalescing stack slots Export this patch

I noticed that my compiler was generating redundant blits, and after
looking through the QBE debug output I believe that I found some low
hanging fruit to help clean them up.

I'm new to this codebase, so please treat this patch with a lot of
skepticism. Happy to make any changes.
Thanks for reviewing, and thank you for QBE!

---
 mem.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/mem.c b/mem.c
index 944cd2f..3f41fa5 100644
--- a/mem.c
+++ b/mem.c
@@ -447,10 +447,15 @@ coalesce(Fn *fn)
		if (i->op == Oblit0)
		if (slot(&s, &off0, i->arg[0], fn, sl))
		if (slot(&s0, &off1, i->arg[1], fn, sl))
		if (s->s == s0->s && off0 < off1) {
			sz = rsval((i+1)->arg[0]);
			assert(sz >= 0);
			(i+1)->arg[0] = INT(-sz);
		if (s->s == s0->s) {
			if (off0 < off1) {
				sz = rsval((i+1)->arg[0]);
				assert(sz >= 0);
				(i+1)->arg[0] = INT(-sz);
			} else if (off0 == off1) {
				*i = (Ins){.op = Onop};
				*(i+1) = (Ins){.op = Onop};
			}
		}
	}
	vfree(bl);
-- 
2.44.0