summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--main.c2
-rw-r--r--mem.c5
2 files changed, 5 insertions, 2 deletions
diff --git a/main.c b/main.c
index f93af37..fe68ae0 100644
--- 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
index ea0bef7..11527fa 100644
--- 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;
 				}