From patchwork Wed May 22 22:28:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164908 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1414287ili; Wed, 22 May 2019 15:32:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqyJSEozNNl7eDOE6iWdId2x3c+vJO0gftJzeNRD76JoitkLtE4i9Zv2oSdObb2u8o7EQsQ8 X-Received: by 2002:a17:906:cc92:: with SMTP id oq18mr47152460ejb.230.1558564366651; Wed, 22 May 2019 15:32:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558564366; cv=none; d=google.com; s=arc-20160816; b=Hm0S2dlm8Rs0oARmZurJSf1FZGHSn1nghmLcqkr/Q+2Dcs/vKdTh+TpVHO2ve8sqm0 TaliGgF6G0zc5eyRMilwDdMyRsL7poqXkPXSAIOet1m31h+c64e9PPzNyVqdOP11Vxn3 RE4YLyLb7LSJ6FMj9TADT3W54e1PYZIOJ8xd8VutvS4/WXK1peMNL65/pRfn6s7sSNV3 QbVQtBqK9xX5JzTbTrEdmPBPLjyjKnKOANXQAQINU6+dZ812SZ3o7iOMFGv4bFx7BK9Q Po7FdwahucTU3DjUMT/0odJAxU7PvrSVly/BmWTKigCziDRVbMgVeEoJpmZp1oTeDGGy tzqA== 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; bh=zqTcnSP07QNrvm+tUagQdKAYnifB03tbX5A/KwjlV2s=; b=VEtFjkt1ACcet0qNpI7elOgTrumXeRSpYHA+G01GMWBDw/xJWufPip+zS7pl3eEVdV PAs1frf/8uvm1fARXy401XWOKU9TA2WrvgMl+VxfWKkq4NO8EwCDkXVLbKbNHQjtLtkH BPA7KV7cUSGz8gsmCEeHW/BAu/rNEGbcUmBAmGFrb9kF95a86KdK4GBXBBqrC1cDHXYQ keLCIK5aU1p0/B1l9ZtdVYeCUHjXeayI/fzB02KQkVDUq1ZB4MnrjG9IzI3H9DF1FWJz jTaia529LHMGYqD4ZWmawytMgpAzEAG3aUCQhj51pm73xu7YoxED/M8nmSsLcsNXBNEq Kp0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=vHLqMPz8; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 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. [209.51.188.17]) by mx.google.com with ESMTPS id z10si11458925edd.210.2019.05.22.15.32.46 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 22 May 2019 15:32:46 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=vHLqMPz8; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 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 ([127.0.0.1]:52553 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTZmv-0006Lr-Fu for patch@linaro.org; Wed, 22 May 2019 18:32:45 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49940) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTZj5-0003AJ-1T for qemu-devel@nongnu.org; Wed, 22 May 2019 18:28:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hTZj3-0007Rq-T0 for qemu-devel@nongnu.org; Wed, 22 May 2019 18:28:47 -0400 Received: from mail-yb1-xb41.google.com ([2607:f8b0:4864:20::b41]:39426) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hTZj3-0007Oh-M0 for qemu-devel@nongnu.org; Wed, 22 May 2019 18:28:45 -0400 Received: by mail-yb1-xb41.google.com with SMTP id a3so1497865ybr.6 for ; Wed, 22 May 2019 15:28:39 -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=zqTcnSP07QNrvm+tUagQdKAYnifB03tbX5A/KwjlV2s=; b=vHLqMPz8J/gynRtyHVBP88iG0jkx2yiVgPnPTwl0Lv4sZOHAqz+2y0MzGm+Fb80gQn ABWS0hICVxt9Yc+jWCw65SBN6Zbgh2XbM2QAexK2TdbchjY8ReImCWbqmJywqdt4X1Rm K5h1yGNdkJDflEKYRGKeAPvhOfUACsYaemQXo8KnYDk7M8/YkzqChJ1ecSsntTdhYSNq D4iDkfxMiZ2ubb4bMNwPtYcsFGBrfq+r2XQDd/HPAeR/mD8/zJaOsQU0Ts929xelL+1y s0xcEDhDmeNmMRoI3aCx5CfAEwA/2ePImZb+OepXSrsULwk7SJ3fUd2NSGwHCL6p4Gta lZIA== 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=zqTcnSP07QNrvm+tUagQdKAYnifB03tbX5A/KwjlV2s=; b=uR2qCSTApjOPdMLZt0NR/QRIL6g8J2s7l9sBrIH8CmHbBQ+Buf+/yEAiFy80YOeTQR S8YBeVEEatwNJ+2Q3DkI8X4L2oW3Dr1Cqd/WIhoci/EpON8v7knBI7FQWeARGFnzedd9 do0++sw34MkSBhWJGArTLfK8DgsxPT3DhERiDax6X6ghWwTyQNa2hqWizHsN2Ds3YZjw k12Zytp2FQ5n+BzKppzhu10vrwwSmjJoVcNRBp1MI4v5vRv5FcCFV0o2XKaV6PPDOL0L KJoPYmKv1nBozkZTGU8uBae+9o+rbFLBWiE+iY4Uwpv1RmAVxGDIrDKQavUZlOXWfRjm a3+g== X-Gm-Message-State: APjAAAVz44mqBkw2gankUPYUnHjEupf6fO83BIhNvMVnKAvuH6XUOYx+ 2tQQBwFQNPHLsYLTe6tjsdc+wF7V6P0= X-Received: by 2002:a25:41d0:: with SMTP id o199mr14334076yba.256.1558564119002; Wed, 22 May 2019 15:28:39 -0700 (PDT) Received: from localhost.localdomain ([71.46.56.17]) by smtp.gmail.com with ESMTPSA id q11sm2276453ywg.7.2019.05.22.15.28.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 May 2019 15:28:38 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 22 May 2019 18:28:19 -0400 Message-Id: <20190522222821.23850-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190522222821.23850-1-richard.henderson@linaro.org> References: <20190522222821.23850-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::b41 Subject: [Qemu-devel] [PULL 14/16] tcg/aarch64: Build vector immediates with two insns 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" Use MOVI+ORR or MVNI+BIC in order to build some vector constants, as opposed to dropping them to the constant pool. This includes all 16-bit constants and a similar set of 32-bit constants. Signed-off-by: Richard Henderson --- tcg/aarch64/tcg-target.inc.c | 47 ++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) -- 2.17.1 diff --git a/tcg/aarch64/tcg-target.inc.c b/tcg/aarch64/tcg-target.inc.c index 0b8b733805..52c18074ae 100644 --- a/tcg/aarch64/tcg-target.inc.c +++ b/tcg/aarch64/tcg-target.inc.c @@ -273,6 +273,26 @@ static bool is_fimm64(uint64_t v64, int *cmode, int *imm8) return false; } +/* + * Return non-zero if v32 can be formed by MOVI+ORR. + * Place the parameters for MOVI in (cmode, imm8). + * Return the cmode for ORR; the imm8 can be had via extraction from v32. + */ +static int is_shimm32_pair(uint32_t v32, int *cmode, int *imm8) +{ + int i; + + for (i = 6; i > 0; i -= 2) { + /* Mask out one byte we can add with ORR. */ + uint32_t tmp = v32 & ~(0xffu << (i * 4)); + if (is_shimm32(tmp, cmode, imm8) || + is_soimm32(tmp, cmode, imm8)) { + break; + } + } + return i; +} + static int tcg_target_const_match(tcg_target_long val, TCGType type, const TCGArgConstraint *arg_ct) { @@ -495,6 +515,8 @@ typedef enum { /* AdvSIMD modified immediate */ I3606_MOVI = 0x0f000400, I3606_MVNI = 0x2f000400, + I3606_BIC = 0x2f001400, + I3606_ORR = 0x0f001400, /* AdvSIMD shift by immediate */ I3614_SSHR = 0x0f000400, @@ -843,6 +865,14 @@ static void tcg_out_dupi_vec(TCGContext *s, TCGType type, tcg_out_insn(s, 3606, MVNI, q, rd, 0, cmode, imm8); return; } + + /* + * Otherwise, all remaining constants can be loaded in two insns: + * rd = v16 & 0xff, rd |= v16 & 0xff00. + */ + tcg_out_insn(s, 3606, MOVI, q, rd, 0, 0x8, v16 & 0xff); + tcg_out_insn(s, 3606, ORR, q, rd, 0, 0xa, v16 >> 8); + return; } else if (v64 == dup_const(MO_32, v64)) { uint32_t v32 = v64; uint32_t n32 = ~v32; @@ -858,6 +888,23 @@ static void tcg_out_dupi_vec(TCGContext *s, TCGType type, tcg_out_insn(s, 3606, MVNI, q, rd, 0, cmode, imm8); return; } + + /* + * Restrict the set of constants to those we can load with + * two instructions. Others we load from the pool. + */ + i = is_shimm32_pair(v32, &cmode, &imm8); + if (i) { + tcg_out_insn(s, 3606, MOVI, q, rd, 0, cmode, imm8); + tcg_out_insn(s, 3606, ORR, q, rd, 0, i, extract32(v32, i * 4, 8)); + return; + } + i = is_shimm32_pair(n32, &cmode, &imm8); + if (i) { + tcg_out_insn(s, 3606, MVNI, q, rd, 0, cmode, imm8); + tcg_out_insn(s, 3606, BIC, q, rd, 0, i, extract32(n32, i * 4, 8)); + return; + } } else if (is_fimm64(v64, &cmode, &imm8)) { tcg_out_insn(s, 3606, MOVI, q, rd, 1, cmode, imm8); return;