diff options
| author | Richard McCormack <[email protected]> | 2024-03-30 09:59:39 -0400 |
|---|---|---|
| committer | Quentin Carbonneaux <[email protected]> | 2024-04-03 22:12:36 +0200 |
| commit | c8fc20b8ef5623d7fe4eae5086b132956bf6aa35 (patch) | |
| tree | e259884583b5a14795f7b68c07266b57ae37a4d3 /mem.c | |
| parent | 85827e2232d65920ddc2d6323d9dea8f9de0cf89 (diff) | |
Eliminate fully overlapping blits after coalescing stack slots
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!
Diffstat (limited to 'mem.c')
| -rw-r--r-- | mem.c | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -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); |
