From 16fe5c13668d9ccc8f3b14c6c20565dfe5a26d57 Mon Sep 17 00:00:00 2001 From: Quentin Carbonneaux Date: Sun, 16 Aug 2015 11:34:52 -0400 Subject: compile branches on and using test --- lisc/isel.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'lisc/isel.c') diff --git a/lisc/isel.c b/lisc/isel.c index 97a0124..41ff9f2 100644 --- a/lisc/isel.c +++ b/lisc/isel.c @@ -173,6 +173,10 @@ sel(Ins i, Fn *fn) break; case ONop: break; + case OXTestw: + case OXTestl: + n = 2; + goto Emit; case OAdd: case OSub: case OAnd: @@ -318,15 +322,26 @@ seljmp(Blk *b, Fn *fn) selcmp(fi->arg, fn); *fi = (Ins){ONop, R, {R, R}}; } - } else { - if (fn->tmp[r.val].nuse == 1) - emit(OCopy, R, r, R); + return; + } + if (fi->op == OAnd && fn->tmp[r.val].nuse == 1 + && (rtype(fi->arg[0]) == RTmp || + rtype(fi->arg[1]) == RTmp)) { + if (fn->tmp[r.val].type == TLong) + fi->op = OXTestl; + else + fi->op = OXTestw; + fi->to = R; b->jmp.type = JXJc + Cne; + return; + } + if (fn->tmp[r.val].nuse > 1) { + b->jmp.type = JXJc + Cne; + return; } - } else { - selcmp((Ref[2]){r, CON_Z}, fn); - b->jmp.type = JXJc + Cne; } + selcmp((Ref[2]){r, CON_Z}, fn); + b->jmp.type = JXJc + Cne; } int -- cgit 1.4.1