From nobody Tue Feb 10 12:13:56 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1558564484; cv=none; d=zoho.com; s=zohoarc; b=mZ/qIhbU26f/g7rqaB3o8tMhH/YFXxM1WZrHwUUo9iYHVxCbJOu5KkfARed8QNPQeSNXY06ZrR+Eun4EuvT6NiRWW+KloGk89pMyVHJMzPm9trrKB9j4xIyPQ34sbfAAoy1UpMUbAFm2Beeacss0ZRPDRLJOX5cNmrOVPRHI8o0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558564484; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=zqTcnSP07QNrvm+tUagQdKAYnifB03tbX5A/KwjlV2s=; b=MqFXuGs34mSHoyUbhnxRleM66kfOlGvSvRlnNfw7zfAn39ys0D3vd1a4/H6KszXkRnz7A0Zmy8unp7LIMroQCzx3FrMknXzp2BIifUZaCnGVhUcTfVHxGOb36xObdMON4wq1ge5fzNJrzEKtYqFi2aPRuotkF83iqmEV0e20Y4Y= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15585644843001001.8308473115387; Wed, 22 May 2019 15:34:44 -0700 (PDT) Received: from localhost ([127.0.0.1]:52561 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTZoj-0007Sr-9v for importer@patchew.org; Wed, 22 May 2019 18:34:37 -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) 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) 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-Google-Smtp-Source: APXvYqynJkXef2+B+QAcUOYy8kkHRKMnS2cw9746NknL7yMp9dtX5wY6GHpHgDd3ioGQhRz2f4Ppqw== X-Received: by 2002:a25:41d0:: with SMTP id o199mr14334076yba.256.1558564119002; Wed, 22 May 2019 15:28:39 -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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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(+) 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 *i= mm8) return false; } =20 +/* + * 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 =3D 6; i > 0; i -=3D 2) { + /* Mask out one byte we can add with ORR. */ + uint32_t tmp =3D 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 =3D 0x0f000400, I3606_MVNI =3D 0x2f000400, + I3606_BIC =3D 0x2f001400, + I3606_ORR =3D 0x0f001400, =20 /* AdvSIMD shift by immediate */ I3614_SSHR =3D 0x0f000400, @@ -843,6 +865,14 @@ static void tcg_out_dupi_vec(TCGContext *s, TCGType ty= pe, tcg_out_insn(s, 3606, MVNI, q, rd, 0, cmode, imm8); return; } + + /* + * Otherwise, all remaining constants can be loaded in two insns: + * rd =3D v16 & 0xff, rd |=3D 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 =3D=3D dup_const(MO_32, v64)) { uint32_t v32 =3D v64; uint32_t n32 =3D ~v32; @@ -858,6 +888,23 @@ static void tcg_out_dupi_vec(TCGContext *s, TCGType ty= pe, 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 =3D 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 =3D 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; --=20 2.17.1