From patchwork Thu Aug 31 03:09:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 718948 Delivered-To: patch@linaro.org Received: by 2002:adf:e5c2:0:b0:31d:da82:a3b4 with SMTP id a2csp244869wrn; Wed, 30 Aug 2023 20:09:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGSYhQl95j8PPSe1nzav96IrnXvzuuh7eWbiUpv8uN019r7lnuQc4AZovq8AkG93n6mH4qr X-Received: by 2002:a05:620a:4450:b0:768:1db5:d9d1 with SMTP id w16-20020a05620a445000b007681db5d9d1mr2267487qkp.5.1693451387685; Wed, 30 Aug 2023 20:09:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693451387; cv=none; d=google.com; s=arc-20160816; b=FK16X8IxvFKBmEGoq3aXK8jRU59y4aJCCLeXxyZENeat+54nG7u0Ce2Jn3J7BkmrnK sCvUroUk3LogPT8Wfij3vv6z9SyYvAVGKhjqRPfh8a//weCETiuA562WVcdNa92O4MOn gE7O41MunElrCWb/1WvVzfjKkvqayrwTogge0xgmVyRv9Rz4L8qr4Y7zHE26f6z6V55D x4yqZQZ90rJhhGevKBoLNb3vyZwp/S6uSLWhPIn3oolvfKkomL+Yk4aeKJucSnvhwFHZ 6GvXzBPyQ3QhhEsX9n2VKfhdHivtRVGy9wApZMGGVcT3jlGKcuK9pU35OLbw6Y2vl4gl Ks6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; 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=QM/ygpbDhjXok8n1tNVzNzKRPAlYOM02I0f2FURZ52s=; fh=legojzL0NBjNCMcvXYgHWqhi5VvhbuKc83OjI5AWfTg=; b=WD1qBYQDKxTxTFi3cSun9mQ/bF9ax4kPnw4nSUYo29L/tFtDaRfboAFJyeg7LKv+RE P5nucym8sgHMJzhnG6C5P254x5RGx6JzCbiYvmK0G73MlnIHBZ2SQT5qMQqhM1dpZ6L6 LrvSG5YPeiX7WE5e2/CNixKvBP3Eix+k51Pzo9WPczJ8NeWHWek499XEylPy7HHTU+Qy D4c/rdtBLcSY1T8KLrGgtcwUOztd45RZUsui0RXh7VLNnBtSt+zAjxKubbk8XOdvxJym BK3gx+iP4xLvt5VzTFTABYCVNe08uhU/USNa8K+P8fBFytDRsutkm/vHNpTLXRvEwzql +sgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Hk6HS+bL; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id y6-20020a05620a25c600b0076811f91fc2si408335qko.124.2023.08.30.20.09.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 30 Aug 2023 20:09:47 -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=Hk6HS+bL; 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 Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qbY3W-0005LS-US; Wed, 30 Aug 2023 23:09:15 -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 1qbY3S-0005Ky-El for qemu-devel@nongnu.org; Wed, 30 Aug 2023 23:09:10 -0400 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qbY3P-0001Fl-RW for qemu-devel@nongnu.org; Wed, 30 Aug 2023 23:09:10 -0400 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1bc63ef9959so2497575ad.2 for ; Wed, 30 Aug 2023 20:09:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693451346; x=1694056146; 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=QM/ygpbDhjXok8n1tNVzNzKRPAlYOM02I0f2FURZ52s=; b=Hk6HS+bL6b+oaGgQPt11NH7k496BVxLh5ZXmH0fFBhoRs0U4SOaB83jVd6x23RrnpK vbM+Bs5JG34l024RruaqPSitbwCjevLRonp4PMntN37qwYZWaWv71alcqZohefvdKgFe oYUmp6M4yVjEM1F3ZqHieHoVFsZX6TfV69n/GiH1lVG4yIGo5RhR2hBcAC7APFvTiTYW SN/3M9V6aanLaveP8QjsqppsyInBxmcsgqP/jroXeV3R16Xqn58LO69U1/AhhR1MyBDd Fyglj2ji9OTPMF6LfsU0D0yScidm26YppWhTwENK5xaT/CGQqyps8F/GKTXU/lgas9XB 3YLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693451346; x=1694056146; 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=QM/ygpbDhjXok8n1tNVzNzKRPAlYOM02I0f2FURZ52s=; b=IsEwwyzXZRw3iTXe9kWvuNti1o3y/FIn2Sdwru91n9mjsH6kXxk8GRMRDmDb25Nckm 67DFnS0GzO457qtFQ7GrM6GO/6bW1sTFPIoa10PsdQr/lECJF2NMay2qz0O8K1VVZS3c 1J1wOjB8M7U5s7yeCWr16QKdRj+uyhO1bG6lxrTYYRulbpvzzqGc1oU3+DChgbiytAg3 8ydiUY1bgRACltvAVBCwVRYAybB7Vu/bSkIg5/KCYx21GPN9wvJ12YjTeOj0J8Bq7oVl TlB6MMKQSwjVarZD2BFP/5Gxi07imMUZi0xo8b9NCKcH6bOLntNziCPysRP6wYXLUpVJ Ynsg== X-Gm-Message-State: AOJu0YwFYADFd0U48sn6g1mMzGsvsuU2h7mzmKfyV88i0GvOXSm6OyCU nzY0GsmRrnaU/xbW4I3lPygzI/ldGWy28HLOVQw= X-Received: by 2002:a17:903:1c4:b0:1bd:d911:2a85 with SMTP id e4-20020a17090301c400b001bdd9112a85mr4516604plh.12.1693451346640; Wed, 30 Aug 2023 20:09:06 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id ix21-20020a170902f81500b001bba7aab826sm225123plb.163.2023.08.30.20.09.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Aug 2023 20:09:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: gaosong@loongson.cn Subject: [PATCH 1/2] tcg: Add gvec compare with immediate and scalar operand Date: Wed, 30 Aug 2023 20:09:03 -0700 Message-Id: <20230831030904.1194667-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230831030904.1194667-1-richard.henderson@linaro.org> References: <20230831030904.1194667-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::634; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x634.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 Signed-off-by: Richard Henderson Tested-by: Song Gao Reviewed-by: Song Gao --- accel/tcg/tcg-runtime.h | 25 ++++++ include/tcg/tcg-op-gvec-common.h | 6 ++ accel/tcg/tcg-runtime-gvec.c | 26 ++++++ tcg/tcg-op-gvec.c | 150 +++++++++++++++++++++++++++++++ 4 files changed, 207 insertions(+) diff --git a/accel/tcg/tcg-runtime.h b/accel/tcg/tcg-runtime.h index 186899a2c7..c23b5e66c4 100644 --- a/accel/tcg/tcg-runtime.h +++ b/accel/tcg/tcg-runtime.h @@ -297,4 +297,29 @@ DEF_HELPER_FLAGS_4(gvec_leu16, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) DEF_HELPER_FLAGS_4(gvec_leu32, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) DEF_HELPER_FLAGS_4(gvec_leu64, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(gvec_eqs8, TCG_CALL_NO_RWG, void, ptr, ptr, i64, i32) +DEF_HELPER_FLAGS_4(gvec_eqs16, TCG_CALL_NO_RWG, void, ptr, ptr, i64, i32) +DEF_HELPER_FLAGS_4(gvec_eqs32, TCG_CALL_NO_RWG, void, ptr, ptr, i64, i32) +DEF_HELPER_FLAGS_4(gvec_eqs64, TCG_CALL_NO_RWG, void, ptr, ptr, i64, i32) + +DEF_HELPER_FLAGS_4(gvec_lts8, TCG_CALL_NO_RWG, void, ptr, ptr, i64, i32) +DEF_HELPER_FLAGS_4(gvec_lts16, TCG_CALL_NO_RWG, void, ptr, ptr, i64, i32) +DEF_HELPER_FLAGS_4(gvec_lts32, TCG_CALL_NO_RWG, void, ptr, ptr, i64, i32) +DEF_HELPER_FLAGS_4(gvec_lts64, TCG_CALL_NO_RWG, void, ptr, ptr, i64, i32) + +DEF_HELPER_FLAGS_4(gvec_les8, TCG_CALL_NO_RWG, void, ptr, ptr, i64, i32) +DEF_HELPER_FLAGS_4(gvec_les16, TCG_CALL_NO_RWG, void, ptr, ptr, i64, i32) +DEF_HELPER_FLAGS_4(gvec_les32, TCG_CALL_NO_RWG, void, ptr, ptr, i64, i32) +DEF_HELPER_FLAGS_4(gvec_les64, TCG_CALL_NO_RWG, void, ptr, ptr, i64, i32) + +DEF_HELPER_FLAGS_4(gvec_ltus8, TCG_CALL_NO_RWG, void, ptr, ptr, i64, i32) +DEF_HELPER_FLAGS_4(gvec_ltus16, TCG_CALL_NO_RWG, void, ptr, ptr, i64, i32) +DEF_HELPER_FLAGS_4(gvec_ltus32, TCG_CALL_NO_RWG, void, ptr, ptr, i64, i32) +DEF_HELPER_FLAGS_4(gvec_ltus64, TCG_CALL_NO_RWG, void, ptr, ptr, i64, i32) + +DEF_HELPER_FLAGS_4(gvec_leus8, TCG_CALL_NO_RWG, void, ptr, ptr, i64, i32) +DEF_HELPER_FLAGS_4(gvec_leus16, TCG_CALL_NO_RWG, void, ptr, ptr, i64, i32) +DEF_HELPER_FLAGS_4(gvec_leus32, TCG_CALL_NO_RWG, void, ptr, ptr, i64, i32) +DEF_HELPER_FLAGS_4(gvec_leus64, TCG_CALL_NO_RWG, void, ptr, ptr, i64, i32) + DEF_HELPER_FLAGS_5(gvec_bitsel, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32) diff --git a/include/tcg/tcg-op-gvec-common.h b/include/tcg/tcg-op-gvec-common.h index e2683d487f..4db8a58c14 100644 --- a/include/tcg/tcg-op-gvec-common.h +++ b/include/tcg/tcg-op-gvec-common.h @@ -374,6 +374,12 @@ void tcg_gen_gvec_rotrv(unsigned vece, uint32_t dofs, uint32_t aofs, void tcg_gen_gvec_cmp(TCGCond cond, unsigned vece, uint32_t dofs, uint32_t aofs, uint32_t bofs, uint32_t oprsz, uint32_t maxsz); +void tcg_gen_gvec_cmpi(TCGCond cond, unsigned vece, uint32_t dofs, + uint32_t aofs, int64_t c, + uint32_t oprsz, uint32_t maxsz); +void tcg_gen_gvec_cmps(TCGCond cond, unsigned vece, uint32_t dofs, + uint32_t aofs, TCGv_i64 c, + uint32_t oprsz, uint32_t maxsz); /* * Perform vector bit select: d = (b & a) | (c & ~a). diff --git a/accel/tcg/tcg-runtime-gvec.c b/accel/tcg/tcg-runtime-gvec.c index 6c99f952ca..afca89baa1 100644 --- a/accel/tcg/tcg-runtime-gvec.c +++ b/accel/tcg/tcg-runtime-gvec.c @@ -1042,6 +1042,32 @@ DO_CMP2(64) #undef DO_CMP1 #undef DO_CMP2 +#define DO_CMP1(NAME, TYPE, OP) \ +void HELPER(NAME)(void *d, void *a, uint64_t b64, uint32_t desc) \ +{ \ + intptr_t oprsz = simd_oprsz(desc); \ + TYPE inv = simd_data(desc), b = b64; \ + for (intptr_t i = 0; i < oprsz; i += sizeof(TYPE)) { \ + *(TYPE *)(d + i) = -((*(TYPE *)(a + i) OP b) ^ inv); \ + } \ + clear_high(d, oprsz, desc); \ +} + +#define DO_CMP2(SZ) \ + DO_CMP1(gvec_eqs##SZ, uint##SZ##_t, ==) \ + DO_CMP1(gvec_lts##SZ, int##SZ##_t, <) \ + DO_CMP1(gvec_les##SZ, int##SZ##_t, <=) \ + DO_CMP1(gvec_ltus##SZ, uint##SZ##_t, <) \ + DO_CMP1(gvec_leus##SZ, uint##SZ##_t, <=) + +DO_CMP2(8) +DO_CMP2(16) +DO_CMP2(32) +DO_CMP2(64) + +#undef DO_CMP1 +#undef DO_CMP2 + void HELPER(gvec_ssadd8)(void *d, void *a, void *b, uint32_t desc) { intptr_t oprsz = simd_oprsz(desc); diff --git a/tcg/tcg-op-gvec.c b/tcg/tcg-op-gvec.c index f5cfd9bf99..f7ca9e1051 100644 --- a/tcg/tcg-op-gvec.c +++ b/tcg/tcg-op-gvec.c @@ -3819,6 +3819,156 @@ void tcg_gen_gvec_cmp(TCGCond cond, unsigned vece, uint32_t dofs, } } +void tcg_gen_gvec_cmps(TCGCond cond, unsigned vece, uint32_t dofs, + uint32_t aofs, TCGv_i64 c, + uint32_t oprsz, uint32_t maxsz) +{ + static const TCGOpcode cmp_list[] = { INDEX_op_cmp_vec, 0 }; + static gen_helper_gvec_2i * const eq_fn[4] = { + gen_helper_gvec_eqs8, gen_helper_gvec_eqs16, + gen_helper_gvec_eqs32, gen_helper_gvec_eqs64 + }; + static gen_helper_gvec_2i * const lt_fn[4] = { + gen_helper_gvec_lts8, gen_helper_gvec_lts16, + gen_helper_gvec_lts32, gen_helper_gvec_lts64 + }; + static gen_helper_gvec_2i * const le_fn[4] = { + gen_helper_gvec_les8, gen_helper_gvec_les16, + gen_helper_gvec_les32, gen_helper_gvec_les64 + }; + static gen_helper_gvec_2i * const ltu_fn[4] = { + gen_helper_gvec_ltus8, gen_helper_gvec_ltus16, + gen_helper_gvec_ltus32, gen_helper_gvec_ltus64 + }; + static gen_helper_gvec_2i * const leu_fn[4] = { + gen_helper_gvec_leus8, gen_helper_gvec_leus16, + gen_helper_gvec_leus32, gen_helper_gvec_leus64 + }; + static gen_helper_gvec_2i * const * const fns[16] = { + [TCG_COND_EQ] = eq_fn, + [TCG_COND_LT] = lt_fn, + [TCG_COND_LE] = le_fn, + [TCG_COND_LTU] = ltu_fn, + [TCG_COND_LEU] = leu_fn, + }; + + TCGType type; + + check_size_align(oprsz, maxsz, dofs | aofs); + check_overlap_2(dofs, aofs, maxsz); + + if (cond == TCG_COND_NEVER || cond == TCG_COND_ALWAYS) { + do_dup(MO_8, dofs, oprsz, maxsz, + NULL, NULL, -(cond == TCG_COND_ALWAYS)); + return; + } + + /* + * Implement inline with a vector type, if possible. + * Prefer integer when 64-bit host and 64-bit comparison. + */ + type = choose_vector_type(cmp_list, vece, oprsz, + TCG_TARGET_REG_BITS == 64 && vece == MO_64); + if (type != 0) { + const TCGOpcode *hold_list = tcg_swap_vecop_list(cmp_list); + TCGv_vec t_vec = tcg_temp_new_vec(type); + uint32_t some, i; + + tcg_gen_dup_i64_vec(vece, t_vec, c); + + switch (type) { + case TCG_TYPE_V256: + some = QEMU_ALIGN_DOWN(oprsz, 32); + for (i = 0; i < some; i += 32) { + TCGv_vec t0 = tcg_temp_new_vec(TCG_TYPE_V256); + TCGv_vec t1 = tcg_temp_new_vec(TCG_TYPE_V256); + tcg_gen_ld_vec(t0, cpu_env, aofs); + tcg_gen_cmp_vec(cond, vece, t0, t1, t_vec); + tcg_gen_st_vec(t0, cpu_env, dofs); + aofs += 32; + dofs += 32; + } + oprsz -= some; + maxsz -= some; + /* fallthru */ + + case TCG_TYPE_V128: + some = QEMU_ALIGN_DOWN(oprsz, 16); + for (i = 0; i < some; i += 16) { + TCGv_vec t0 = tcg_temp_new_vec(TCG_TYPE_V128); + TCGv_vec t1 = tcg_temp_new_vec(TCG_TYPE_V128); + tcg_gen_ld_vec(t0, cpu_env, aofs + i); + tcg_gen_cmp_vec(cond, vece, t0, t1, t_vec); + tcg_gen_st_vec(t0, cpu_env, dofs + i); + } + break; + + case TCG_TYPE_V64: + some = QEMU_ALIGN_DOWN(oprsz, 8); + for (i = 0; i < some; i += 8) { + TCGv_vec t0 = tcg_temp_new_vec(TCG_TYPE_V64); + TCGv_vec t1 = tcg_temp_new_vec(TCG_TYPE_V64); + tcg_gen_ld_vec(t0, cpu_env, aofs + i); + tcg_gen_cmp_vec(cond, vece, t0, t1, t_vec); + tcg_gen_st_vec(t0, cpu_env, dofs + i); + } + break; + + default: + g_assert_not_reached(); + } + tcg_temp_free_vec(t_vec); + tcg_swap_vecop_list(hold_list); + } else if (vece == MO_64 && check_size_impl(oprsz, 8)) { + TCGv_i64 t0 = tcg_temp_ebb_new_i64(); + uint32_t i; + + for (i = 0; i < oprsz; i += 8) { + tcg_gen_ld_i64(t0, cpu_env, aofs + i); + tcg_gen_negsetcond_i64(cond, t0, t0, c); + tcg_gen_st_i64(t0, cpu_env, dofs + i); + } + tcg_temp_free_i64(t0); + } else if (vece == MO_32 && check_size_impl(oprsz, 4)) { + TCGv_i32 t0 = tcg_temp_ebb_new_i32(); + TCGv_i32 t1 = tcg_temp_ebb_new_i32(); + uint32_t i; + + tcg_gen_extrl_i64_i32(t1, c); + for (i = 0; i < oprsz; i += 8) { + tcg_gen_ld_i32(t0, cpu_env, aofs + i); + tcg_gen_negsetcond_i32(cond, t0, t0, t1); + tcg_gen_st_i32(t0, cpu_env, dofs + i); + } + tcg_temp_free_i32(t0); + tcg_temp_free_i32(t1); + } else { + gen_helper_gvec_2i * const *fn = fns[cond]; + bool inv = false; + + if (fn == NULL) { + cond = tcg_invert_cond(cond); + fn = fns[cond]; + assert(fn != NULL); + inv = true; + } + tcg_gen_gvec_2i_ool(dofs, aofs, c, oprsz, maxsz, inv, fn[vece]); + return; + } + + if (oprsz < maxsz) { + expand_clr(dofs + oprsz, maxsz - oprsz); + } +} + +void tcg_gen_gvec_cmpi(TCGCond cond, unsigned vece, uint32_t dofs, + uint32_t aofs, int64_t c, + uint32_t oprsz, uint32_t maxsz) +{ + TCGv_i64 tmp = tcg_constant_i64(c); + tcg_gen_gvec_cmps(cond, vece, dofs, aofs, tmp, oprsz, maxsz); +} + static void tcg_gen_bitsel_i64(TCGv_i64 d, TCGv_i64 a, TCGv_i64 b, TCGv_i64 c) { TCGv_i64 t = tcg_temp_ebb_new_i64(); From patchwork Thu Aug 31 03:09:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 718950 Delivered-To: patch@linaro.org Received: by 2002:adf:e5c2:0:b0:31d:da82:a3b4 with SMTP id a2csp244937wrn; Wed, 30 Aug 2023 20:10:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IExDFlLOmqx/PRNuj2dAXOszucKSiBIZHaaHvFZCQwaP+PsBhH+zB/WyXg9VIQDFZVz9RAr X-Received: by 2002:a05:600c:ac8:b0:401:eb0:a98d with SMTP id c8-20020a05600c0ac800b004010eb0a98dmr3268360wmr.24.1693451402355; Wed, 30 Aug 2023 20:10:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693451402; cv=none; d=google.com; s=arc-20160816; b=GuRHyFyhodeIBqGGGZwXfjbkIF5pJFrGui83nIBuECjRL05vKTmc8Z1e/vOP9CwNJG fvg0OEKj7/E6INwopCQLIiqO2xXUN8ssOHxZqywl0/6trxgsE07rZyTkollOD+HnBtvb jQp+V3f1mFXP8mOK5torQk+c0XuGQXxpz3TY3NP/dvRCUKQeujduIZ4QwbZrG3evJv0d c4oZdm/3CPHXHKa/ZFbLvEIbnpVfOUL8yzS5DrKq/asSRfscn6hclPsCFhj6snezoSbf /WmVPuvBBNOaBEk0nk+aX9aa/6DQBk2nVtDkwjRtWAGvRUub4vvKFwTxD0IBZLoDNDmT pc7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; 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=WCSUo8NxMzlfmw4OjKURT71L8T30vr4pb5Vh1ZtlO+I=; fh=legojzL0NBjNCMcvXYgHWqhi5VvhbuKc83OjI5AWfTg=; b=O6pSs0mfVM1Q43dcCNfGLXOz9VRExR3TCK8HkHKKQYxy+JNxH72gV9rTVXENSI4+LH 4VgFkQBSQ7ZixVpp5E+MRE6mLNEVam4cc3bSGy2KnClp0Mxa7wKn4Y7m63WpHS9JjdwZ JblDnO/hi73nYpHw0k3gAbGPIEAhJYyzompergC2zzdc+TDe/MSMF36ev4wPerelr5PU r6GxPuJjr7iFpB0pbuwp20uuPT0GIoEPMNsjgJN6gp64zFmTT1Ja+2cbjprHl8ECGRgA afkP3KmwS52dIEV3MEUvlZZle8k/PZA//Q32AGuhiwdGkJpTST5O0AlDitBf+L46UJbh 8vLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KNRDLbOV; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id n1-20020adffe01000000b0030aecd473d3si197469wrr.211.2023.08.30.20.10.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 30 Aug 2023 20:10:02 -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=KNRDLbOV; 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 Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qbY3c-0005MO-NH; Wed, 30 Aug 2023 23:09:20 -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 1qbY3T-0005LB-G4 for qemu-devel@nongnu.org; Wed, 30 Aug 2023 23:09:12 -0400 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qbY3R-0001Fx-4m for qemu-devel@nongnu.org; Wed, 30 Aug 2023 23:09:11 -0400 Received: by mail-pg1-x52b.google.com with SMTP id 41be03b00d2f7-563f8e8a53dso302431a12.3 for ; Wed, 30 Aug 2023 20:09:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693451347; x=1694056147; 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=WCSUo8NxMzlfmw4OjKURT71L8T30vr4pb5Vh1ZtlO+I=; b=KNRDLbOV7CYBDTs+fL6rzy04S72S4/1wLcEI995T6nGhM2ATFHYiDEjuDTDm99yKV0 EQSPQ5aCVr0GPHsmJ/2KcKKkBTS3XBmMTOIeRTecgoTls9DWnVG2iK1QGGREgZZcFQaC 3/LNmh43+RMiZOKwSQyq2kMfAUVCF/dKzbWwXDmmQ7Xj6shEqv661t77YYmp9yxDGBED t1F1ZEuR429+pHu4Mzomettw+Em7N0bJ0u0Nd7bqa/1jjHXT7lTtxfxWgRgaN5VcXJcs JU46iHLD+W1fBt5IHvUPzRKOWAyx/I3w50/rqqNpGqkNauyJ0TXn3vabeXZMX6qDsLRg kuTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693451347; x=1694056147; 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=WCSUo8NxMzlfmw4OjKURT71L8T30vr4pb5Vh1ZtlO+I=; b=GzOvqYQOPS8a9/VHctLniWbwkkr4eJDX8AjiLj599GS7uyCFo1secyIh/RuAzAs7fT MVj4j/W1PMfycztGYvC3/x6bt+jOZsid3udH6LIsBRzh/83T7SSa0a4kYwUF1+sLkcui EabmbfAgBrI3ajbX3IkmiRIr5Dz8yQF2KN4JzPqkWwmhVrY36Wpug+9RsWXaXLh9xSgL Q6mq5D32GpPZkJDxwhk8LZ9BrQwKyEvMTnbxUG5HNCgBn94ENDNtZ9vTNZkXNPzjRis9 MHnKCTaW/PZa+/ANEvOzn7ha69D/ydmdclM+/cHTsWIGNuKKeqAg0EthKRCROWLgWYr7 Fmvg== X-Gm-Message-State: AOJu0YwfQYghGITkEo1/oSE0qo6OusMwKIg/ouoduhLelOZMRiBzcq1q qo3joAdf4szDJ2yYrJ7nCrjuOFKXPt7rw+iO0PQ= X-Received: by 2002:a05:6a20:415:b0:148:9ba1:9f6f with SMTP id a21-20020a056a20041500b001489ba19f6fmr3821246pza.38.1693451347534; Wed, 30 Aug 2023 20:09:07 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id ix21-20020a170902f81500b001bba7aab826sm225123plb.163.2023.08.30.20.09.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Aug 2023 20:09:07 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: gaosong@loongson.cn Subject: [PATCH 2/2] target/arm: Use tcg_gen_gvec_cmpi for compare vs 0 Date: Wed, 30 Aug 2023 20:09:04 -0700 Message-Id: <20230831030904.1194667-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230831030904.1194667-1-richard.henderson@linaro.org> References: <20230831030904.1194667-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52b; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52b.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 Signed-off-by: Richard Henderson Reviewed-by: Song Gao --- target/arm/tcg/translate.c | 56 ++++++-------------------------------- 1 file changed, 9 insertions(+), 47 deletions(-) diff --git a/target/arm/tcg/translate.c b/target/arm/tcg/translate.c index 38ad8dd4bd..89a7392ed3 100644 --- a/target/arm/tcg/translate.c +++ b/target/arm/tcg/translate.c @@ -2943,54 +2943,16 @@ void gen_gvec_sqrdmlsh_qc(unsigned vece, uint32_t rd_ofs, uint32_t rn_ofs, gen_gvec_fn3_qc(rd_ofs, rn_ofs, rm_ofs, opr_sz, max_sz, fns[vece - 1]); } -#define GEN_CMP0(NAME, COND) \ - static void gen_##NAME##0_i32(TCGv_i32 d, TCGv_i32 a) \ - { \ - tcg_gen_negsetcond_i32(COND, d, a, tcg_constant_i32(0)); \ - } \ - static void gen_##NAME##0_i64(TCGv_i64 d, TCGv_i64 a) \ - { \ - tcg_gen_negsetcond_i64(COND, d, a, tcg_constant_i64(0)); \ - } \ - static void gen_##NAME##0_vec(unsigned vece, TCGv_vec d, TCGv_vec a) \ - { \ - TCGv_vec zero = tcg_constant_vec_matching(d, vece, 0); \ - tcg_gen_cmp_vec(COND, vece, d, a, zero); \ - } \ - void gen_gvec_##NAME##0(unsigned vece, uint32_t d, uint32_t m, \ - uint32_t opr_sz, uint32_t max_sz) \ - { \ - const GVecGen2 op[4] = { \ - { .fno = gen_helper_gvec_##NAME##0_b, \ - .fniv = gen_##NAME##0_vec, \ - .opt_opc = vecop_list_cmp, \ - .vece = MO_8 }, \ - { .fno = gen_helper_gvec_##NAME##0_h, \ - .fniv = gen_##NAME##0_vec, \ - .opt_opc = vecop_list_cmp, \ - .vece = MO_16 }, \ - { .fni4 = gen_##NAME##0_i32, \ - .fniv = gen_##NAME##0_vec, \ - .opt_opc = vecop_list_cmp, \ - .vece = MO_32 }, \ - { .fni8 = gen_##NAME##0_i64, \ - .fniv = gen_##NAME##0_vec, \ - .opt_opc = vecop_list_cmp, \ - .prefer_i64 = TCG_TARGET_REG_BITS == 64, \ - .vece = MO_64 }, \ - }; \ - tcg_gen_gvec_2(d, m, opr_sz, max_sz, &op[vece]); \ - } +#define GEN_CMP0(NAME, COND) \ + void NAME(unsigned vece, uint32_t d, uint32_t m, \ + uint32_t opr_sz, uint32_t max_sz) \ + { tcg_gen_gvec_cmpi(COND, vece, d, m, 0, opr_sz, max_sz); } -static const TCGOpcode vecop_list_cmp[] = { - INDEX_op_cmp_vec, 0 -}; - -GEN_CMP0(ceq, TCG_COND_EQ) -GEN_CMP0(cle, TCG_COND_LE) -GEN_CMP0(cge, TCG_COND_GE) -GEN_CMP0(clt, TCG_COND_LT) -GEN_CMP0(cgt, TCG_COND_GT) +GEN_CMP0(gen_gvec_ceq0, TCG_COND_EQ) +GEN_CMP0(gen_gvec_cle0, TCG_COND_LE) +GEN_CMP0(gen_gvec_cge0, TCG_COND_GE) +GEN_CMP0(gen_gvec_clt0, TCG_COND_LT) +GEN_CMP0(gen_gvec_cgt0, TCG_COND_GT) #undef GEN_CMP0