From patchwork Tue May 8 15:14:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135179 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp4515839lji; Tue, 8 May 2018 08:19:43 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq6Wu+PQDIyep3U37CI1LktE878Hz5haFku/KesF2jEyryemA7wt6wyZBCrSuiaY6dPlL7m X-Received: by 10.55.194.65 with SMTP id j1mr1551087qkm.108.1525792783099; Tue, 08 May 2018 08:19:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525792783; cv=none; d=google.com; s=arc-20160816; b=kPZl9LQ5/lzWU1Wif45CU7KYdhELHnvT482937fBybAatyaLzwTOL2jxt/1ImkAsb/ dblFFYnqWil/EzmJ9IIOpXnQGcH/SlUxBLj3umT/2N2gdkL+JdaobzVC27G84/UW+eYz KY04Q2o/dyOVN5kjOTcDzXp4u7Ol1aTarildWLS7wnOwrT3u0e6kKKPVHY7Yxb+SiADO V5fWIsaDsgSXokOIYtheAoldnh3RrLOVy1ybqIFp5CXDStRr2Mkm3aZUPa8bZUivF72c BAZc68sob52u+MQGx69GWsLIe94WeQ9ovvoefcsN80jW6TCLLpAmEAGIHkmdS3Kzjleq BmRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=fw6BpfxewIu3YtIiReuneFzbAKyrC+lK3DRHx3c0Yd0=; b=NDDB+pGRc0fRCrJWaL1NIQAfYc83IsBpCkZXMlQtQWpZa2xvl+Algi2qZ0J+3/rSM5 4/Ps+FK8eimCEbJ1Sk6LpjBoU8PRbtMUZczPHu4Dr7x7KzQq6j54Odolx6TIuTvTyr9N 8C2CLecgrPhs4KSpnY8LE9cxqGlJXQU+b2OeR6mYDc9KxEQe8n+1wV35Ri9gxaVYwFBO F3U/TMVVMKVBpBzm8WYvPXpAlqVU6/oXWHNP4MbjDpEqsDneDC7JSly2g+Sd0EA8ntSM F/49fvWm0EyySyACj8iKzHLCTPiSoJ+aIMXqAAKlEQy1/aSjVSPuw9EliHCU83pHg5OC kOQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=KgCMPxxJ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id m10-v6si1663726qtc.129.2018.05.08.08.19.42 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 08 May 2018 08:19:43 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=KgCMPxxJ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:51822 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fG4P0-0000mC-HY for patch@linaro.org; Tue, 08 May 2018 11:19:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59496) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fG4KD-0006YX-Tq for qemu-devel@nongnu.org; Tue, 08 May 2018 11:14:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fG4KC-00087t-PX for qemu-devel@nongnu.org; Tue, 08 May 2018 11:14:45 -0400 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:45547) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fG4KC-00087N-Jb for qemu-devel@nongnu.org; Tue, 08 May 2018 11:14:44 -0400 Received: by mail-pf0-x242.google.com with SMTP id c10so24105242pfi.12 for ; Tue, 08 May 2018 08:14:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fw6BpfxewIu3YtIiReuneFzbAKyrC+lK3DRHx3c0Yd0=; b=KgCMPxxJSH33MYqQEhr060e2rSZo6bIGTDY5K8WfQHbSitadgr/usyp7WKlMBUjcVS t/KDRQFV+NG96NM7STD9zyCqqtVddwrAufc5RzxGhLdYqRRiC9S2Gs48orhQNdWvinMS Ax8MiLypirJo+3f2gIS2N+xoq/BJA9RlL50k0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=fw6BpfxewIu3YtIiReuneFzbAKyrC+lK3DRHx3c0Yd0=; b=gA4gAOdkwzY5Dm8kpanY+TzjFbRjPzl9Bc3hbHapFx6Rn9AN8miXilZnmWpBASoslg T8o4lR1ARwQxo42f3K7Ear1f47ySKVBEQavMIB+N4oZQqaZ2LMeqQZbBUg6kYYPoHQbI uO2pxhQTGb+gLBYh3no06gpFPUtFHE6mmHoluXk29oqM/zrB5qcjeMlqipU+/Q4GqrwF HqiDruaIu9KFOwQe10eB8P72TT2QA4V0UFju06u5GlV5RH5usKCXJN+jW5R31tB/vqGt H7SRDCNkWWsJVRf/R5GYbr1b7yUnyYIdfs1Yb4PM99rthPGt7I7FCixRRdLbIWtupbiC Janw== X-Gm-Message-State: ALQs6tBCV3TXxKaFQibdk3nWWc1XBE9YVcUhOQsqCszFF9ydKL8K5b/B cac36FiONeXlt3GT7yHNSGY0SDhwEZg= X-Received: by 2002:a65:4189:: with SMTP id a9-v6mr32840918pgq.118.1525792483353; Tue, 08 May 2018 08:14:43 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id n10sm55598896pfj.68.2018.05.08.08.14.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 08 May 2018 08:14:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 8 May 2018 08:14:30 -0700 Message-Id: <20180508151437.4232-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180508151437.4232-1-richard.henderson@linaro.org> References: <20180508151437.4232-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::242 Subject: [Qemu-devel] [PATCH v3 03/10] target/xtensa: Use new min/max expanders X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The generic expanders replace nearly identical code in the translator. Acked-by: Max Filippov Signed-off-by: Richard Henderson --- target/xtensa/translate.c | 50 ++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 17 deletions(-) -- 2.17.0 diff --git a/target/xtensa/translate.c b/target/xtensa/translate.c index 4f6d03059f..bad5cdb009 100644 --- a/target/xtensa/translate.c +++ b/target/xtensa/translate.c @@ -1527,10 +1527,8 @@ static void translate_clamps(DisasContext *dc, const uint32_t arg[], TCGv_i32 tmp1 = tcg_const_i32(-1u << arg[2]); TCGv_i32 tmp2 = tcg_const_i32((1 << arg[2]) - 1); - tcg_gen_movcond_i32(TCG_COND_GT, tmp1, - cpu_R[arg[1]], tmp1, cpu_R[arg[1]], tmp1); - tcg_gen_movcond_i32(TCG_COND_LT, cpu_R[arg[0]], - tmp1, tmp2, tmp1, tmp2); + tcg_gen_smax_i32(tmp1, tmp1, cpu_R[arg[1]]); + tcg_gen_smin_i32(cpu_R[arg[0]], tmp1, tmp2); tcg_temp_free(tmp1); tcg_temp_free(tmp2); } @@ -1855,13 +1853,35 @@ static void translate_memw(DisasContext *dc, const uint32_t arg[], tcg_gen_mb(TCG_BAR_SC | TCG_MO_ALL); } -static void translate_minmax(DisasContext *dc, const uint32_t arg[], - const uint32_t par[]) +static void translate_smin(DisasContext *dc, const uint32_t arg[], + const uint32_t par[]) { if (gen_window_check3(dc, arg[0], arg[1], arg[2])) { - tcg_gen_movcond_i32(par[0], cpu_R[arg[0]], - cpu_R[arg[1]], cpu_R[arg[2]], - cpu_R[arg[1]], cpu_R[arg[2]]); + tcg_gen_smin_i32(cpu_R[arg[0]], cpu_R[arg[1]], cpu_R[arg[2]]); + } +} + +static void translate_umin(DisasContext *dc, const uint32_t arg[], + const uint32_t par[]) +{ + if (gen_window_check3(dc, arg[0], arg[1], arg[2])) { + tcg_gen_umin_i32(cpu_R[arg[0]], cpu_R[arg[1]], cpu_R[arg[2]]); + } +} + +static void translate_smax(DisasContext *dc, const uint32_t arg[], + const uint32_t par[]) +{ + if (gen_window_check3(dc, arg[0], arg[1], arg[2])) { + tcg_gen_smax_i32(cpu_R[arg[0]], cpu_R[arg[1]], cpu_R[arg[2]]); + } +} + +static void translate_umax(DisasContext *dc, const uint32_t arg[], + const uint32_t par[]) +{ + if (gen_window_check3(dc, arg[0], arg[1], arg[2])) { + tcg_gen_umax_i32(cpu_R[arg[0]], cpu_R[arg[1]], cpu_R[arg[2]]); } } @@ -2984,23 +3004,19 @@ static const XtensaOpcodeOps core_ops[] = { .par = (const uint32_t[]){TCG_COND_NE}, }, { .name = "max", - .translate = translate_minmax, - .par = (const uint32_t[]){TCG_COND_GE}, + .translate = translate_smax, }, { .name = "maxu", - .translate = translate_minmax, - .par = (const uint32_t[]){TCG_COND_GEU}, + .translate = translate_umax, }, { .name = "memw", .translate = translate_memw, }, { .name = "min", - .translate = translate_minmax, - .par = (const uint32_t[]){TCG_COND_LT}, + .translate = translate_smin, }, { .name = "minu", - .translate = translate_minmax, - .par = (const uint32_t[]){TCG_COND_LTU}, + .translate = translate_umin, }, { .name = "mov", .translate = translate_mov,