qbe

Internal scc patchset buffer for QBE
Log | Files | Refs | README | LICENSE

commit f3301026fa404c68c7ad399b5a56a5135b88af04
parent fc124dd22e6d936de53c60f6752e45c857f10013
Author: Quentin Carbonneaux <quentin.carbonneaux@yale.edu>
Date:   Fri, 24 Feb 2017 09:42:12 -0500

reenable and fix a bug in memopt

While a minimal dead store elimination is not
implemented, the generated code looks quite a
bit better with them enabled.  It also is quite
cheap.

Diffstat:
Mmain.c | 2+-
Mmem.c | 5++++-
2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/main.c b/main.c @@ -50,7 +50,7 @@ func(Fn *fn) fillrpo(fn); fillpreds(fn); filluse(fn); - /* memopt(fn); */ + memopt(fn); ssa(fn); filluse(fn); ssacheck(fn); diff --git a/mem.c b/mem.c @@ -86,15 +86,18 @@ memopt(Fn *fn) /* try to turn loads into copies so we * can eliminate them later */ switch(l->op) { - case Oload: case Oloadsw: case Oloaduw: + if (k == Kl) + goto Extend; + case Oload: if (KBASE(k) != KBASE(l->cls)) l->op = Ocast; else l->op = Ocopy; break; default: + Extend: l->op = Oextsb + (l->op - Oloadsb); break; }