From nobody Sun Nov 24 09:00:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1726073608; cv=none; d=zohomail.com; s=zohoarc; b=BpBh1TUwmqbqC1dgZZQsTclE/dTIXJxAfPfVNBAtxad4DZdj5fCdnaBQe2xO9DS21byEjhOM3lWDwUdc3ZYW52gMIhASTvlfWxZI2lgZhbyNvXG0tUFq3+tnYtB3VVrIcSgH0z4MbM03yhCOcv2PSIHh9K91OAUbaY7rxeLV9gM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726073608; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=r4uFa1EewNZVM8eb9T0XGX/kCpjVJLtWV1XZpTNAvas=; b=Kq+JSlRdOH4hxt1VqdovRG2Pcn6frW2BUALunewKKPTMYnoC2qDGK2tQkwHXYXqb0iDHMGrJlnKH4iWWg+joR7J+dR0r8lgZnn9VKoL4teWswGqzoExZaLHxVNdf2lqTLjCYZmpRTVp9Jgkqy5mdV9GggIHRfF6CTfxDplO3FZg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1726073608508123.33376460243755; Wed, 11 Sep 2024 09:53:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1soQYo-0003Ku-99; Wed, 11 Sep 2024 12:51:19 -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 1soQYd-0002hJ-QU for qemu-devel@nongnu.org; Wed, 11 Sep 2024 12:51:09 -0400 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1soQYb-0003h0-JO for qemu-devel@nongnu.org; Wed, 11 Sep 2024 12:51:07 -0400 Received: by mail-pg1-x530.google.com with SMTP id 41be03b00d2f7-7db19de6346so54437a12.2 for ; Wed, 11 Sep 2024 09:51:05 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71908fe4e7esm3186947b3a.80.2024.09.11.09.51.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 09:51:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1726073464; x=1726678264; 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=r4uFa1EewNZVM8eb9T0XGX/kCpjVJLtWV1XZpTNAvas=; b=QdGBNTQnAezKjfSfr/ApFHdNcyHyjKNX0YlCMNL6WeTQsR48n3pFAPIu2/9sbepw6Z P0RotgXBqtB+S+rbEQz/XiVbiBaGlW/bnXEWQSGgQAd6Eguko/TNHYZQqcGEx8Tteg7d HWYZm3n+8aQePZiNi4Fx1WbF57z0BcKn6G3zhY1DstSpcORV6gGH3uvUa+Js5/9TdV28 R4bl39PXAJi1S33q5seJzVVzej9myICzBprSpNFFkCtkEbad4LjQ+VG/8Dg01IjRKWbW A8vUN7os+iUqBnwBiNZ2kLaSi8cU0rBTNgWiSwoD2HhOW6sGlWOjRU0gbA5ra7BlYA4G CF0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726073464; x=1726678264; 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=r4uFa1EewNZVM8eb9T0XGX/kCpjVJLtWV1XZpTNAvas=; b=QTmMr1QVPfKkhapriSqbXofydBMJJL6SziTwaqV8KkWfqzne2jGcMVkn9LDyeisDg2 QVxtxzUWJA9Pip8gPcLS3EeOFWcfC+wDMIhol6PPbIiIITTav43bzcQCqTqFYHqwNLTH kH3LXCa2hVUTgo+NCP3goYk/TzgrEIGhqi04sGgwzXEq4LsZSJYNaIsV4rPEKtIDO4t6 +wCH6c2Y70OAZlfCSYBnwqWbGoENxojwKr9CiwZIMQGUPwSpjCKKM9AkL5FxFB+Dz8WC QbuL2bmt+XWpWqi83SIM3BpMIz1JqrXKs8MJ2cA5VMxIo9JpFAoXCI874JrHbSsnQflW z8Jg== X-Gm-Message-State: AOJu0Yxcl1CpplapGK2H3xHZJLsjI0Xo5IZV82VRXSGIg7ioOTBHtkec Txdw7W0BSUZDRIUKQkwTXj51N9DOvB2cZlrqvbALCXC5WI/AAfYuzf46eEJzr1N7sKFtY+CuDT3 E X-Google-Smtp-Source: AGHT+IF7gXFmjuuN+NHTysq0ASm6dtsiywMSCg5hW/S37U0mgcwmqlONYH48C53btduETInqf5/UiQ== X-Received: by 2002:a05:6a20:85a6:b0:1cf:6d68:4a0 with SMTP id adf61e73a8af0-1cf6d68118amr1871707637.22.1726073464058; Wed, 11 Sep 2024 09:51:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: zhiwei_liu@linux.alibaba.com, tangtiancheng.ttc@alibaba-inc.com, philmd@linaro.org Subject: [PATCH v2 16/18] tcg/ppc: Optimize cmpsel with constant 0/-1 arguments Date: Wed, 11 Sep 2024 09:50:45 -0700 Message-ID: <20240911165047.1035764-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240911165047.1035764-1-richard.henderson@linaro.org> References: <20240911165047.1035764-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=2607:f8b0:4864:20::530; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x530.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1726073610850116600 Content-Type: text/plain; charset="utf-8" These can be simplified to and/or/andc/orc, avoiding the load of the constantinto a register. Signed-off-by: Richard Henderson --- tcg/ppc/tcg-target-con-set.h | 2 +- tcg/ppc/tcg-target.c.inc | 43 +++++++++++++++++++++++++++--------- 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/tcg/ppc/tcg-target-con-set.h b/tcg/ppc/tcg-target-con-set.h index e7ba00c248..453abde6c1 100644 --- a/tcg/ppc/tcg-target-con-set.h +++ b/tcg/ppc/tcg-target-con-set.h @@ -33,7 +33,7 @@ C_O1_I2(r, r, rU) C_O1_I2(r, r, rZW) C_O1_I2(v, v, v) C_O1_I3(v, v, v, v) -C_O1_I4(v, v, v, v, v) +C_O1_I4(v, v, v, vZM, v) C_O1_I4(r, r, rC, rZ, rZ) C_O1_I4(r, r, r, ri, ri) C_O2_I1(r, r, r) diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index 9d07b4d8e6..3f413ce3c1 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -3725,6 +3725,11 @@ static void tcg_out_or_vec(TCGContext *s, TCGReg a0,= TCGReg a1, TCGReg a2) tcg_out32(s, VOR | VRT(a0) | VRA(a1) | VRB(a2)); } =20 +static void tcg_out_orc_vec(TCGContext *s, TCGReg a0, TCGReg a1, TCGReg a2) +{ + tcg_out32(s, VORC | VRT(a0) | VRA(a1) | VRB(a2)); +} + static void tcg_out_and_vec(TCGContext *s, TCGReg a0, TCGReg a1, TCGReg a2) { tcg_out32(s, VAND | VRT(a0) | VRA(a1) | VRB(a2)); @@ -3827,15 +3832,30 @@ static void tcg_out_cmp_vec(TCGContext *s, unsigned= vece, TCGReg a0, } =20 static void tcg_out_cmpsel_vec(TCGContext *s, unsigned vece, TCGReg a0, - TCGReg c1, TCGReg c2, TCGReg v3, TCGReg v4, - TCGCond cond) + TCGReg c1, TCGReg c2, TCGArg v3, int const_= v3, + TCGReg v4, TCGCond cond) { - if (tcg_out_cmp_vec_noinv(s, vece, TCG_VEC_TMP1, c1, c2, cond)) { - TCGReg swap =3D v3; - v3 =3D v4; - v4 =3D swap; + bool inv =3D tcg_out_cmp_vec_noinv(s, vece, TCG_VEC_TMP1, c1, c2, cond= ); + + if (!const_v3) { + if (inv) { + tcg_out_bitsel_vec(s, a0, TCG_VEC_TMP1, v4, v3); + } else { + tcg_out_bitsel_vec(s, a0, TCG_VEC_TMP1, v3, v4); + } + } else if (v3) { + if (inv) { + tcg_out_orc_vec(s, a0, v4, TCG_VEC_TMP1); + } else { + tcg_out_or_vec(s, a0, v4, TCG_VEC_TMP1); + } + } else { + if (inv) { + tcg_out_and_vec(s, a0, v4, TCG_VEC_TMP1); + } else { + tcg_out_andc_vec(s, a0, v4, TCG_VEC_TMP1); + } } - tcg_out_bitsel_vec(s, a0, TCG_VEC_TMP1, v3, v4); } =20 static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, @@ -3944,8 +3964,8 @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode o= pc, tcg_out_not_vec(s, a0, a1); return; case INDEX_op_orc_vec: - insn =3D VORC; - break; + tcg_out_orc_vec(s, a0, a1, a2); + return; case INDEX_op_nand_vec: insn =3D VNAND; break; @@ -3960,7 +3980,8 @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode o= pc, tcg_out_cmp_vec(s, vece, a0, a1, a2, args[3]); return; case INDEX_op_cmpsel_vec: - tcg_out_cmpsel_vec(s, vece, a0, a1, a2, args[3], args[4], args[5]); + tcg_out_cmpsel_vec(s, vece, a0, a1, a2, + args[3], const_args[3], args[4], args[5]); return; case INDEX_op_bitsel_vec: tcg_out_bitsel_vec(s, a0, a1, a2, args[3]); @@ -4330,7 +4351,7 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpc= ode op) case INDEX_op_ppc_msum_vec: return C_O1_I3(v, v, v, v); case INDEX_op_cmpsel_vec: - return C_O1_I4(v, v, v, v, v); + return C_O1_I4(v, v, v, vZM, v); =20 default: g_assert_not_reached(); --=20 2.43.0