change cmp $0, %reg, to test %reg, %reg

This commit is contained in:
Quentin Carbonneaux 2015-08-20 11:56:48 -04:00
parent fd31290dd3
commit 1abed68cc3

View file

@ -261,6 +261,11 @@ eins(Ins i, Fn *fn, FILE *f)
break; break;
case OXCmpw: case OXCmpw:
case OXCmpl: case OXCmpl:
if (rtype(i.arg[1]) == RTmp && req(i.arg[0], CON_Z)) {
eop("test", i.arg[1], i.arg[1], fn, f);
break;
}
/* fall through */
case OXTestw: case OXTestw:
case OXTestl: case OXTestl:
eop(otoa[i.op], i.arg[0], i.arg[1], fn, f); eop(otoa[i.op], i.arg[0], i.arg[1], fn, f);