From patchwork Thu Sep 12 02:40:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 827745 Delivered-To: patch@linaro.org Received: by 2002:adf:ab1c:0:b0:367:895a:4699 with SMTP id q28csp1070907wrc; Wed, 11 Sep 2024 19:43:07 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCViW3c78qhDLlNwTO/e/lcQgOUyf008cffxERrhuL14037yoRW2wZwNLZRT3ZEIS8GhovMMWg==@linaro.org X-Google-Smtp-Source: AGHT+IF61pgKtdI7gryWXdddC/129DHbqDLCPVrVOU1EGk8o9/GKk8Lthh8lkRDX3GgDxqI8x8T3 X-Received: by 2002:a05:6214:3a8b:b0:6c5:1151:8cbe with SMTP id 6a1803df08f44-6c57357bf88mr20127966d6.38.1726108986978; Wed, 11 Sep 2024 19:43:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1726108986; cv=none; d=google.com; s=arc-20240605; b=dZJa2+EZHVx+KGdQPGj4HAq8FFDGnl362kbDvwAr+buOhf8/oiv5ZOfPlXvkjigEod aENb7Mfbdg/tIx5EUJ8ysGXjplXOsZhhZLjUnsWImfV6lWbhbAl4vJsxL7G1zJVgPemF /pYqeshZ4xF9s2vJrxeuIgpXqEWLBpHjwojdih/LiRGztykmH6wWsGx+yp+XXC/E3/Ud wknfDGAUaridyQFZJiitg81qO/lDNZullnGUZYDAUycdHr5+J9byTA0He6DQvSPJVmJx 5Y9kaBZ39JZDmDZcFThBdjv1dygOGAaV9rY9KpeuwKxEPoZhRal+5gz6z7Co0jlqlgF1 /Vpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=htF5qh+BwrQAazett+74anTVYDcrx88zDGCrAO2eD7Q=; fh=ZhBia3nL9o1nuf7SbgdYn/0pDmAeja6gisyWXi2cqYE=; b=dHcGxqVfqL5Lh9sRifljOLCXnTwvr0Qg+/2qjF9fiThd5nPIuX6gY0udPq9/qWchEs jDhloJBHZRUUUS+A5wP+QsxLRxv3vzD7V2nNjAmjLpvGnse3M7gSenHMymb6FrQwJPmo JzL1risGD0NemHJm5d+vWcDhdHkO97oE4olGBJKweXNzuDXYKhDxn2/4i7lL6MR7FZsN /eqG2iiytXdqCpyWRB0jUxi0tMJSpmTEHdX1801XyLU5bMSuhPCKSf1QOv55mqAfRgwk m1FKQy2Igy6c91eiSrLFDhiy9mtckYDHWAHfEOk87caxjAsxlYX6iMKpaVrbFL1yA/9q AMEA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zEwKls3D; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6c53476fb05si117728836d6.221.2024.09.11.19.43.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Sep 2024 19:43:06 -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=pass header.i=@linaro.org header.s=google header.b=zEwKls3D; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1soZm5-0003OX-Ft; Wed, 11 Sep 2024 22:41:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1soZlw-0002kw-2U for qemu-devel@nongnu.org; Wed, 11 Sep 2024 22:41:28 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1soZlu-00049p-00 for qemu-devel@nongnu.org; Wed, 11 Sep 2024 22:41:27 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-2068acc8b98so4717325ad.3 for ; Wed, 11 Sep 2024 19:41:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1726108885; x=1726713685; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=htF5qh+BwrQAazett+74anTVYDcrx88zDGCrAO2eD7Q=; b=zEwKls3DyIInNlLldxJGMvfd73Aiw/7LX6w0tr/oEfv8eRNdDS1XdTbq/o7UPIJWvG G7KW0D3Y9N3Y1WShUWDjsJ+3zYNE5qgWQYTTp48rDqo+Cz9cuG8JLNsTApgCzRhd2SPT hEhcnWPVLj0M57zDYWYtnaC21KlND5SCe26uTYKztHe4blY7/7LeIcehdsGSgKwUHgKA jAlU/NWOXmI39x9AN5WYuOsbNQO+9bJaplFreIJbq2PBPUSzFlGpmvhgkUje4we2V+pp 2T9ShhTIvM6AubkwChPvwpcOsGdxD3oXwWI8ze8tKjJvnXkxXM78s2bQWbzK2o0vIG0L Ji2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726108885; x=1726713685; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=htF5qh+BwrQAazett+74anTVYDcrx88zDGCrAO2eD7Q=; b=PWdd1KHPcds3GDrGUnNa0Fy/WXqinys+X4ysYSSQQFdPb04UwYskaWcAjdXW5v0gyN mCZSPxNpkKDjZbvgq434Reg2rI5XowJoMwrc3YPygtyiAn1VF4CgnSRnYFqXWuSoYk9c J0pc6ScYBfV0BnUON3oeqU15H7vbmFBE+CofVPxkBGIVvBFkudUUFCoWDHbebR/do6OV vSSKmnPnn9Dzj2cvLgNvc712gHVTmQFmlBZ89MQOff9x9lPAZqIK6tSCTv1MpWMcYqK1 1T5FMxT2DipIM/cLmI7r8ZjiqkrplneNB2jPLRyyZ1p0f7tdtgOCxWijotevIT1BZPPm 420w== X-Gm-Message-State: AOJu0YwK3nNsi1tgBiqAhQkaqCWH7b04rYU1DNHFq78E8VzVYK4b91gx pX9CIPeDLOQDdTMDjcijVvQ04E1PVQKpoU/58Vrdgl8WJdS3ACrsTbm3/ntcyLWHvhJ/RHqotaB / X-Received: by 2002:a17:902:d4c1:b0:205:913b:d9ad with SMTP id d9443c01a7336-2076d6268ffmr17109915ad.0.1726108884628; Wed, 11 Sep 2024 19:41:24 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2076afe9c61sm5635915ad.231.2024.09.11.19.41.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 19:41:24 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell Subject: [PATCH v3 09/29] target/arm: Simplify do_reduction_op Date: Wed, 11 Sep 2024 19:40:54 -0700 Message-ID: <20240912024114.1097832-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240912024114.1097832-1-richard.henderson@linaro.org> References: <20240912024114.1097832-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Use simple shift and add instead of ctpop, ctz, shift and mask. Unlike SVE, there is no predicate to disable elements. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/tcg/translate-a64.c | 40 +++++++++++----------------------- 1 file changed, 13 insertions(+), 27 deletions(-) diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 04160b2513..74efb35164 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -9027,34 +9027,23 @@ static void disas_data_proc_fp(DisasContext *s, uint32_t insn) * important for correct NaN propagation that we do these * operations in exactly the order specified by the pseudocode. * - * This is a recursive function, TCG temps should be freed by the - * calling function once it is done with the values. + * This is a recursive function. */ static TCGv_i32 do_reduction_op(DisasContext *s, int fpopcode, int rn, - int esize, int size, int vmap, TCGv_ptr fpst) + MemOp esz, int ebase, int ecount, TCGv_ptr fpst) { - if (esize == size) { - int element; - MemOp msize = esize == 16 ? MO_16 : MO_32; - TCGv_i32 tcg_elem; - - /* We should have one register left here */ - assert(ctpop8(vmap) == 1); - element = ctz32(vmap); - assert(element < 8); - - tcg_elem = tcg_temp_new_i32(); - read_vec_element_i32(s, tcg_elem, rn, element, msize); + if (ecount == 1) { + TCGv_i32 tcg_elem = tcg_temp_new_i32(); + read_vec_element_i32(s, tcg_elem, rn, ebase, esz); return tcg_elem; } else { - int bits = size / 2; - int shift = ctpop8(vmap) / 2; - int vmap_lo = (vmap >> shift) & vmap; - int vmap_hi = (vmap & ~vmap_lo); + int half = ecount >> 1; TCGv_i32 tcg_hi, tcg_lo, tcg_res; - tcg_hi = do_reduction_op(s, fpopcode, rn, esize, bits, vmap_hi, fpst); - tcg_lo = do_reduction_op(s, fpopcode, rn, esize, bits, vmap_lo, fpst); + tcg_hi = do_reduction_op(s, fpopcode, rn, esz, + ebase + half, half, fpst); + tcg_lo = do_reduction_op(s, fpopcode, rn, esz, + ebase, half, fpst); tcg_res = tcg_temp_new_i32(); switch (fpopcode) { @@ -9105,7 +9094,6 @@ static void disas_simd_across_lanes(DisasContext *s, uint32_t insn) bool is_u = extract32(insn, 29, 1); bool is_fp = false; bool is_min = false; - int esize; int elements; int i; TCGv_i64 tcg_res, tcg_elt; @@ -9152,8 +9140,7 @@ static void disas_simd_across_lanes(DisasContext *s, uint32_t insn) return; } - esize = 8 << size; - elements = (is_q ? 128 : 64) / esize; + elements = (is_q ? 16 : 8) >> size; tcg_res = tcg_temp_new_i64(); tcg_elt = tcg_temp_new_i64(); @@ -9208,9 +9195,8 @@ static void disas_simd_across_lanes(DisasContext *s, uint32_t insn) */ TCGv_ptr fpst = fpstatus_ptr(size == MO_16 ? FPST_FPCR_F16 : FPST_FPCR); int fpopcode = opcode | is_min << 4 | is_u << 5; - int vmap = (1 << elements) - 1; - TCGv_i32 tcg_res32 = do_reduction_op(s, fpopcode, rn, esize, - (is_q ? 128 : 64), vmap, fpst); + TCGv_i32 tcg_res32 = do_reduction_op(s, fpopcode, rn, size, + 0, elements, fpst); tcg_gen_extu_i32_i64(tcg_res, tcg_res32); }