From 078522cf5d5b7adbe56fb1300e47f642616354d5 Mon Sep 17 00:00:00 2001 From: Quentin Carbonneaux Date: Wed, 5 Aug 2015 16:13:18 -0400 Subject: use a temporary for constant comparisons --- lisc/isel.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'lisc/isel.c') diff --git a/lisc/isel.c b/lisc/isel.c index faea3b5..ea4aa01 100644 --- a/lisc/isel.c +++ b/lisc/isel.c @@ -86,15 +86,25 @@ sel(Ins i, Fn *fn) break; default: if (OCmp <= i.op && i.op <= OCmp1) { + r0 = i.arg[0]; c = i.op - OCmp; if (rtype(i.arg[0]) == RCon) { - r0 = i.arg[0]; - i.arg[0] = i.arg[1]; - i.arg[1] = r0; - c = CNEG(c); + if (rtype(i.arg[1]) == RCon) { + /* todo, use the constant + * size to dimension the + * constant */ + t = newtmp(TWord, fn); + r0 = TMP(t); + } else { + r0 = i.arg[1]; + i.arg[1] = i.arg[0]; + c = CNEG(c); + } } emit(OXSet+c, i.to, R, R); - emit(OXCmp, R, i.arg[1], i.arg[0]); + emit(OXCmp, R, i.arg[1], r0); + if (!req(r0, i.arg[0])) + emit(OCopy, r0, i.arg[0], R); break; } diag("isel: non-exhaustive implementation"); -- cgit 1.4.1