From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:44701) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T9f8d-0004BD-AA for qemu-devel@nongnu.org; Thu, 06 Sep 2012 12:41:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T9f8Y-0007kI-Ay for qemu-devel@nongnu.org; Thu, 06 Sep 2012 12:41:07 -0400 Received: from mail-vc0-f173.google.com ([209.85.220.173]:32808) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T9f8Y-0007k7-5T for qemu-devel@nongnu.org; Thu, 06 Sep 2012 12:41:02 -0400 Received: by vcbfl10 with SMTP id fl10so2517950vcb.4 for ; Thu, 06 Sep 2012 09:41:01 -0700 (PDT) Sender: Richard Henderson Message-ID: <5048D219.7070303@twiddle.net> Date: Thu, 06 Sep 2012 09:40:57 -0700 From: Richard Henderson MIME-Version: 1.0 References: <1346943657-17256-1-git-send-email-aurelien@aurel32.net> <1346943657-17256-8-git-send-email-aurelien@aurel32.net> In-Reply-To: <1346943657-17256-8-git-send-email-aurelien@aurel32.net> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 7/8] tcg/optimize: add constant folding for setcond List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Aurelien Jarno Cc: qemu-devel@nongnu.org On 09/06/2012 08:00 AM, Aurelien Jarno wrote: > Signed-off-by: Aurelien Jarno > --- > tcg/optimize.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 79 insertions(+) > > diff --git a/tcg/optimize.c b/tcg/optimize.c > index 7debc8a..c4af1e8 100644 > --- a/tcg/optimize.c > +++ b/tcg/optimize.c > @@ -267,6 +267,65 @@ static TCGArg do_constant_folding(TCGOpcode op, TCGArg x, TCGArg y) > return res; > } > > +static TCGArg do_constant_folding_cond(TCGOpcode op, TCGArg x, > + TCGArg y, TCGCond c) > +{ > + switch (op_bits(op)) { > + case 32: > + switch (c) { > + case TCG_COND_EQ: > + return (uint32_t)x == (uint32_t)y; > + case TCG_COND_NE: > + return (uint32_t)x != (uint32_t)y; > + case TCG_COND_LT: > + return (int32_t)x < (int32_t)y; > + case TCG_COND_GE: > + return (int32_t)x >= (int32_t)y; > + case TCG_COND_LE: > + return (int32_t)x <= (int32_t)y; > + case TCG_COND_GT: > + return (int32_t)x > (int32_t)y; > + case TCG_COND_LTU: > + return (uint32_t)x < (uint32_t)y; > + case TCG_COND_GEU: > + return (uint32_t)x >= (uint32_t)y; > + case TCG_COND_LEU: > + return (uint32_t)x <= (uint32_t)y; > + case TCG_COND_GTU: > + return (uint32_t)x > (uint32_t)y; > + } > + case 64: > + switch (c) { > + case TCG_COND_EQ: > + return (uint64_t)x == (uint64_t)y; > + case TCG_COND_NE: > + return (uint64_t)x != (uint64_t)y; > + case TCG_COND_LT: > + return (int64_t)x < (int64_t)y; > + case TCG_COND_GE: > + return (int64_t)x >= (int64_t)y; > + case TCG_COND_LE: > + return (int64_t)x <= (int64_t)y; > + case TCG_COND_GT: > + return (int64_t)x > (int64_t)y; > + case TCG_COND_LTU: > + return (uint64_t)x < (uint64_t)y; > + case TCG_COND_GEU: > + return (uint64_t)x >= (uint64_t)y; > + case TCG_COND_LEU: > + return (uint64_t)x <= (uint64_t)y; > + case TCG_COND_GTU: > + return (uint64_t)x > (uint64_t)y; > + } > + default: > + fprintf(stderr, > + "Unrecognized bitness %d or condition %d in " > + "do_constant_folding_cond.\n", op_bits(op), c); > + tcg_abort(); > + } You probably don't want the default here, but the statements after the outer switch, and with proper breaks between the two cases. Otherwise the error doesn't do what you wanted it to do. r~