From patchwork Thu Aug 17 18:04:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 110339 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp2528130qge; Thu, 17 Aug 2017 11:12:44 -0700 (PDT) X-Received: by 10.237.58.106 with SMTP id n97mr8806369qte.284.1502993564541; Thu, 17 Aug 2017 11:12:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502993564; cv=none; d=google.com; s=arc-20160816; b=LtyUJbzf78nNAYKnpUBbgh9gqXFuNxOcCHTkDmzUcz/1q2L6fpMVVimSn+GXpGNH+N cIYoWY1St2cVyzncBhDE/fCzKO/3Pz6kPMyUCw9rIZ98gT2or4g1E/DmzwWCnYe668mF 0LY1Dt1XWVF+zUmikzLpJTwnlpKFzPX7wPncjsrDHm5mRZ/Z/ZDs75njj5kyN2wI4Yf8 BXSZzNY9zP6P26buOYIZtju1LbjPeND7JytqfLOI5kVx0hWUxMOtj3QgyakbrRcvTHlE +wuVfvfwmCjNvssEcwcBzhsYRE+3FmvZjGlEuWNQ1IMKO2yJ+Nq8kekp0CU1S0OysszM plvQ== 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 :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=UC4iwuAR4yeyWBSDbELSGaxnBCBHWMws/wQFfSoxQ0g=; b=nqDxsmUCeRzHqiaNBoe+JFwYaQmh8gCmBAdv8YmYaFOEyLW/xURrxXMgffZANCIayy 5UUGJncB6UFDIczRLfwnOsXy7aJPd56CzCyRcAJpZiU4xLeaVHGwOd0knKZGNilNwpcu hyqVukMKRnDojQpmECDJn+Ofs1nEvd3zvBQLQX2l8rMqZFo1o143wt6SMPHbcqfA3oIP iLfWmDBrf9fv5K/1Qf/0qI325Gf5kvfd7iVEDK+pynlxHKz4/MqbDXZzHUtQnco4Hg99 B6w2epad26s/vH+TeqSWF7avnDlFQNJ8/l2rry8tmCW7BWXPKLoBIHRAG1x1/u33xZp7 //KA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=FRRxoY1V; 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 u39si3419665qtu.388.2017.08.17.11.12.44 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 17 Aug 2017 11:12:44 -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=FRRxoY1V; 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]:38667 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1diPHe-0002A2-2L for patch@linaro.org; Thu, 17 Aug 2017 14:12:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37577) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1diP9W-00049O-VY for qemu-devel@nongnu.org; Thu, 17 Aug 2017 14:04:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1diP9V-0005Of-TD for qemu-devel@nongnu.org; Thu, 17 Aug 2017 14:04:18 -0400 Received: from mail-wr0-x22e.google.com ([2a00:1450:400c:c0c::22e]:34032) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1diP9V-0005Nu-Gh for qemu-devel@nongnu.org; Thu, 17 Aug 2017 14:04:17 -0400 Received: by mail-wr0-x22e.google.com with SMTP id y96so47731454wrc.1 for ; Thu, 17 Aug 2017 11:04:17 -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 :mime-version:content-transfer-encoding; bh=UC4iwuAR4yeyWBSDbELSGaxnBCBHWMws/wQFfSoxQ0g=; b=FRRxoY1V+wZWgrDUDBiQAimwI4n4lFdaoYE0qCsrWD9lf0h5ocOy9utlQVqBMAg2bU AT0VFoIohLYSlqYKiHmrBHo2u00Rrt3dkXW3RHVG/WrM///P0XAlZcHBAQ6l45VIAKbK 3h6CRCNHdoR3CBV8eugaOqAjjvh3D4nDll7MM= 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:mime-version:content-transfer-encoding; bh=UC4iwuAR4yeyWBSDbELSGaxnBCBHWMws/wQFfSoxQ0g=; b=gGhQFXaoQPF0czSRIbyQv/U/1A79qjzbfXGfA8d3hSyr0nBl2PDEVxAWwolIkEKhd2 FbprRBbDWRjGkJMC2R76v6i6CHEZmLDABmkS2aVdQGRJ+CTBzJ+G/B83p6hr7PSIapfS OKsbCh9kfbKJmQBJ1dyDsaBPD/UfHordNh/MGyQESPDMUC+dBx9Km+DyqgGkxK66ZmRj m+nyJhHvQKfBsuJ2QtQVqcdICH/0Dy4t7ODflYTwa6Sel7FVjugBRgdGl5+bF9CNb3pR UblWnwEztWpJncutOZzdHu5f8MHMDN15ZshzLhX7ntxVLlK6zT50ef5d6Q1uGPSMlQkH ZElg== X-Gm-Message-State: AHYfb5i9EF7deWAtjigZVJSNS4t7JnHPhCik/xPYFIPodIrtRr0OGrUy 3BGCDSlusRpOEA2n X-Received: by 10.223.152.19 with SMTP id v19mr4134516wrb.60.1502993056413; Thu, 17 Aug 2017 11:04:16 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id f9sm3877162wmf.9.2017.08.17.11.04.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Aug 2017 11:04:10 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 2A0ED3E1403; Thu, 17 Aug 2017 19:04:05 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: rth@twiddle.net, cota@braap.org, batuzovk@ispras.ru Date: Thu, 17 Aug 2017 19:04:04 +0100 Message-Id: <20170817180404.29334-10-alex.bennee@linaro.org> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170817180404.29334-1-alex.bennee@linaro.org> References: <20170817180404.29334-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::22e Subject: [Qemu-devel] [RFC PATCH 9/9] target/arm/translate-a64: vectorise smull vD.4s, vN.[48]s, vM.h[] 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 , qemu-arm@nongnu.org, =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" These instructions show up in the ffmpeg profile from the ff_simple_idct_put_neon function. WARNING: this is experimental and essentially shortcuts to the vectorised helper for the one instruction that shows up a lot in the ffmpeg trace. Otherwise it falls through to the normal code generation. We also skip where rd == rn to avoid having to explicitly deal with the aliasing in the helper. Signed-off-by: Alex Bennée --- target/arm/helper-a64.c | 17 +++++++++++ target/arm/helper-a64.h | 2 ++ target/arm/translate-a64.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+) -- 2.13.0 diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c index 17b1edfb5f..ae0f8da5c4 100644 --- a/target/arm/helper-a64.c +++ b/target/arm/helper-a64.c @@ -538,3 +538,20 @@ uint64_t HELPER(paired_cmpxchg64_be)(CPUARMState *env, uint64_t addr, return !success; } + +/* Multiply Long (vector, by element) */ +void HELPER(advsimd_smull_idx_s32)(void *d, void *n, uint32_t m, + uint32_t simd_data) +{ + int opr_elt = GET_SIMD_DATA(OPR_ELT, simd_data); + int doff_elt = GET_SIMD_DATA(DOFF_ELT, simd_data); + int32_t *rd = (int32_t *) d; + int16_t *rn = (int16_t *) n; + int16_t rm = (int16_t) m; + int i; + + #pragma GCC ivdep + for (i = 0; i < opr_elt; ++i) { + rd[i] = rn[i + doff_elt] * rm; + } +} diff --git a/target/arm/helper-a64.h b/target/arm/helper-a64.h index 6f9eaba533..0bd7942cec 100644 --- a/target/arm/helper-a64.h +++ b/target/arm/helper-a64.h @@ -44,3 +44,5 @@ DEF_HELPER_FLAGS_3(crc32_64, TCG_CALL_NO_RWG_SE, i64, i64, i64, i32) DEF_HELPER_FLAGS_3(crc32c_64, TCG_CALL_NO_RWG_SE, i64, i64, i64, i32) DEF_HELPER_FLAGS_4(paired_cmpxchg64_le, TCG_CALL_NO_WG, i64, env, i64, i64, i64) DEF_HELPER_FLAGS_4(paired_cmpxchg64_be, TCG_CALL_NO_WG, i64, env, i64, i64, i64) + +DEF_HELPER_4(advsimd_smull_idx_s32, void, vec, vec, i32, i32) diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index f474c5008b..3a609e571c 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -10466,6 +10466,74 @@ static void disas_simd_two_reg_misc(DisasContext *s, uint32_t insn) } } +typedef void AdvSIMDGenTwoPlusOneVectorFn(TCGv_vec, TCGv_vec, TCGv_i32, TCGv_i32); + +/* Handle [U/S]ML[S/A]L instructions + * + * This splits off from bellow only to aid experimentation. + */ +static bool handle_vec_simd_mul_addsub(DisasContext *s, uint32_t insn, int opcode, int size, bool is_q, bool u, int rn, int rm, int rd) +{ + /* fprintf(stderr, "%s: %#04x op:%x sz:%d rn:%d rm:%d rd:%d\n", __func__, */ + /* insn, opcode, size, rn, rm, rd); */ + + if (size == 1) { + AdvSIMDGenTwoPlusOneVectorFn *fn = NULL; + uint32_t simd_info = 0; + + switch (opcode) { + case 0x2: /* SMLAL, SMLAL2, UMLAL, UMLAL2 */ + break; + case 0x6: /* SMLSL, SMLSL2, UMLSL, UMLSL2 */ + break; + case 0xa: /* SMULL, SMULL2, UMULL, UMULL2 */ + if (!u) + { + /* helper assumes no aliasing */ + if (rd == rn) { + return false; + } + + fn = gen_helper_advsimd_smull_idx_s32; + simd_info = deposit32(simd_info, + ADVSIMD_OPR_ELT_SHIFT, ADVSIMD_OPR_ELT_BITS, 4); + + if (is_q) { + simd_info = deposit32(simd_info, + ADVSIMD_DOFF_ELT_SHIFT, ADVSIMD_DOFF_ELT_BITS, 4); + } + }; + break; + default: + break; + } + + /* assert(fn); */ + + if (fn) { + TCGv_i32 tcg_idx = tcg_temp_new_i32(); + TCGv_i32 tcg_simd_info = tcg_const_i32(simd_info); + int h = extract32(insn, 11, 1); + int lm = extract32(insn, 20, 2); + int index = h << 2 | lm; + + if (!fp_access_check(s)) { + return false; + } + + read_vec_element_i32(s, tcg_idx, rm, index, size); + + fn(cpu_V[rd], cpu_V[rn], tcg_idx, tcg_simd_info); + + tcg_temp_free_i32(tcg_simd_info); + tcg_temp_free_i32(tcg_idx); + return true; + } + } + + return false; +} + /* C3.6.13 AdvSIMD scalar x indexed element * 31 30 29 28 24 23 22 21 20 19 16 15 12 11 10 9 5 4 0 * +-----+---+-----------+------+---+---+------+-----+---+---+------+------+ @@ -10518,6 +10586,10 @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn) unallocated_encoding(s); return; } + /* Shortcut if we have a vectorised helper */ + if (handle_vec_simd_mul_addsub(s, insn, opcode, size, is_q, u, rn, rm, rd)) { + return; + } is_long = true; break; case 0x3: /* SQDMLAL, SQDMLAL2 */