diff options
author | Quentin Carbonneaux <quentin.carbonneaux@yale.edu> | 2015-08-16 11:34:52 -0400 |
---|---|---|
committer | Quentin Carbonneaux <quentin.carbonneaux@yale.edu> | 2015-09-15 23:01:31 -0400 |
commit | 16fe5c13668d9ccc8f3b14c6c20565dfe5a26d57 (patch) | |
tree | 70a7bce825b8d57b74d776c8e2292369a12e97c5 /lisc/isel.c | |
parent | ca3dc70ff3e4caf57f32e5a0da7be29ccf222213 (diff) | |
download | roux-16fe5c13668d9ccc8f3b14c6c20565dfe5a26d57.tar.gz |
compile branches on and using test
Diffstat (limited to 'lisc/isel.c')
-rw-r--r-- | lisc/isel.c | 27 |
1 files changed, 21 insertions, 6 deletions
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 |