commit 7ce4d334e54433f7e67d91baa9edb25adb26975b
parent d37db3970f06e46d1ea9b55084e065e799b09576
Author: Quentin Carbonneaux <quentin.carbonneaux@yale.edu>
Date: Tue, 11 Aug 2015 19:49:52 -0400
add a small size optimization to emit
Diffstat:
1 file changed, 9 insertions(+), 0 deletions(-)
diff --git a/lisc/emit.c b/lisc/emit.c
@@ -141,6 +141,7 @@ eins(Ins i, Fn *fn, FILE *f)
[OStoreb - OStorel] = "b",
};
int r;
+ int64_t val;
switch (i.op) {
case OAdd:
@@ -159,6 +160,14 @@ eins(Ins i, Fn *fn, FILE *f)
eop(otoa[i.op], i.arg[1], i.to, fn, f);
break;
case OCopy:
+ if (i.to.val < EAX && rtype(i.arg[0]) == RCon) {
+ val = fn->con[i.arg[0].val].val;
+ if (0 <= val && val <= UINT32_MAX) {
+ fprintf(f, "\tmov $%"PRId64", %%%s\n",
+ val, rsub[i.to.val][SWord]);
+ break;
+ }
+ }
if (!req(i.arg[0], i.to))
eop("mov", i.arg[0], i.to, fn, f);
break;