From patchwork Fri Mar 29 22:31:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 784105 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e01:0:b0:33e:7753:30bd with SMTP id p1csp3429454wrt; Fri, 29 Mar 2024 15:34:02 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVXu/T4ZQy1y4WXZrlUob08BG12R3oTCpkDPEXQqE1nOerHGMndMNHp2Mn8AwAmrMFKJjCWDPoIB3ZNm4HkzJ8K X-Google-Smtp-Source: AGHT+IHXYxlAu5gVQofxU9m1x6zve/QkMz9htLbdUiKKGvArcQ7+6eus7+pGNeeVfrXMJlXkd3ko X-Received: by 2002:ac8:5941:0:b0:431:6e46:ab4c with SMTP id 1-20020ac85941000000b004316e46ab4cmr4158331qtz.54.1711751642031; Fri, 29 Mar 2024 15:34:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1711751642; cv=none; d=google.com; s=arc-20160816; b=NChWwkrjRmH9n2peqrJQO6NjOsSY7ZVS2KEvxFotG4Zty32DAw9jhm4DmYab/w7Se5 Ev+hMvjIX1XOKRoMY5HQHK+j94fgKYxPEgkKK0vLjDIKvzs8CqSEHAZzBwJ2fngiN4YX Yyc3AQztsQ7WiBENBA+UErX0NYPC5NQb4iCxtAAFesovAM1QqdQ0Ddqf3N5p0OeM9AJI PcC5JWD77iaRb9sMyPyNDGZMA8S+rwZgOxFNCY6tK/O8K5quaKNW1xAH9Pu66bH0b1oz M6OcX9RhZ2XvaHfwL+b7xmeE5xAqnDo9NtF7Y8X+lEdTUk5QXH+aVQdwgGubGCPxScnW MK2w== 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=vnjhMc8AFUnASgt/GDELAcE24oYis+MaL1Mj1wovAY4=; fh=wDljmxUHXfz9MGj2//jPHYRc53BMWF157v8rVKELrf4=; b=TTZgVN4ujCGIw2GAeg/ukVC/BfNeN84/sGYwiUtctQVo+Y82Z4DSlpx2wBcL3aS0Px qs+NNHaNfb5R7JF64o+HYpg0mnKoMkgDqe9IEi/zSLg0eepyrouEhpY4AzCb0TiAj3YC P2x7UyJIWMoMhIpnt4pEoMsLBdTVI2f2DNYtQfFEpfuXm/bu2mTBV93r7S4kvlS9LyJA 5W3lpDryF/haKhyM9Ur6PrjvdUk98S3T4blR5GPV0BCjU5kcntaXNVQAOc6JUdiuqHB5 PBZ7lI+xVxY7EAf6ancvnxQ4HG+mYnBlEndoh89qjXykbLzorAYWZeuWq+sDrW8Wogl8 erAg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RG1tjgff; 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 h12-20020ac8584c000000b0042f5123b42asi4586593qth.370.2024.03.29.15.34.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 29 Mar 2024 15:34: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=RG1tjgff; 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 1rqKlD-0002av-5y; Fri, 29 Mar 2024 18:31:43 -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 1rqKl1-0002Y6-Uf for qemu-devel@nongnu.org; Fri, 29 Mar 2024 18:31:36 -0400 Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rqKkz-0003Wc-HF for qemu-devel@nongnu.org; Fri, 29 Mar 2024 18:31:30 -0400 Received: by mail-pg1-x52a.google.com with SMTP id 41be03b00d2f7-5bdbe2de25fso1672392a12.3 for ; Fri, 29 Mar 2024 15:31:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711751488; x=1712356288; 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=vnjhMc8AFUnASgt/GDELAcE24oYis+MaL1Mj1wovAY4=; b=RG1tjgffITsdDVYuB3zO8zD0pkUa30msVIMRLpIs9x17/FIVL4FkF722biIW8w1iuv 5M8JiKvwjZSAPWppEvFbj44jhuityzume5REoaqjn36yf0XORA0DTiI117g6DM6lTpY1 oUFyCr09YMpuV90KzXMeHNNVCv4ROxq2jI1Qu+Z6Gvoxn0FSHI+WOinyUFTvwLt4K/ri rL7a3wrPVwiro69sRhtxRrN0QwXpKMdXFZRlfsnR/jAc4OkfzeqbOBfN8Sp1xiJTdHig VnFQPF44WNohC67z571Ub2lDJnj/5/wwK8HPM9RlkfQ9WutZHyMopejpMLkipWp36rpA IOFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711751488; x=1712356288; 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=vnjhMc8AFUnASgt/GDELAcE24oYis+MaL1Mj1wovAY4=; b=D+8ZTfsvJsHwvn/zhj2cg9fMSGhX5TDISO4xBhrSN09LfzrDM8zh/mkSvafDjN+MuY OWGMLmUUYVicwV41v9/0Twi/kk0+WR42oEl6oj3YgSTarmjLJz7uUO+1vLgFK9d1HHCZ zIJhS5C2qgV4orD6T0BqSF4bRlBP57GItdikLFT5p7oqmDD5jhzThWZ1FapbX9uHJaul 2nJOA7C35a9w+Zcxk/Q6pWfXMI30DE8kHRzNunMroZCnbxrhCZqrUZVllkaZXOj6qXiA ue/uXJG7PFSI1a7A/7bO+PUH8xjhbgtgETjbHqUVfF/ldoOaJ97E+fOM3CuD/ausNxs4 CGRw== X-Gm-Message-State: AOJu0YwbsaO2pX6CcuMzzoVlLGmvxrkjPdnbPtXmSufvGHL312V3u2am q85xUOGQKtx0Fjl2/86l3oAG3yXp6fItxIB32jxKujWdEcObTKmZOhvrCkKjm7rutQChnMbhTEB 5 X-Received: by 2002:a17:902:e94f:b0:1e2:306c:32e3 with SMTP id b15-20020a170902e94f00b001e2306c32e3mr4188941pll.2.1711751488327; Fri, 29 Mar 2024 15:31:28 -0700 (PDT) Received: from stoup.. (098-147-007-212.res.spectrum.com. [98.147.7.212]) by smtp.gmail.com with ESMTPSA id f8-20020a170902684800b001e09b636cafsm4000955pln.287.2024.03.29.15.31.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 15:31:27 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Helge Deller Subject: [PULL 10/18] target/hppa: Optimize UADDCM with no condition Date: Fri, 29 Mar 2024 12:31:03 -1000 Message-Id: <20240329223111.1735826-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240329223111.1735826-1-richard.henderson@linaro.org> References: <20240329223111.1735826-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52a; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52a.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 With r1 as zero is by far the most common usage of UADDCM, as the easiest way to invert a register. The compiler does occasionally use the addition step as well, and we can simplify that to avoid a temp and write directly into the destination. Tested-by: Helge Deller Reviewed-by: Helge Deller Signed-off-by: Richard Henderson --- target/hppa/translate.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/target/hppa/translate.c b/target/hppa/translate.c index a3f425d861..3fc3e7754c 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -2763,9 +2763,29 @@ static bool do_uaddcm(DisasContext *ctx, arg_rrr_cf_d *a, bool is_tc) { TCGv_i64 tcg_r1, tcg_r2, tmp; - if (a->cf) { - nullify_over(ctx); + if (a->cf == 0) { + tcg_r2 = load_gpr(ctx, a->r2); + tmp = dest_gpr(ctx, a->t); + + if (a->r1 == 0) { + /* UADDCM r0,src,dst is the common idiom for dst = ~src. */ + tcg_gen_not_i64(tmp, tcg_r2); + } else { + /* + * Recall that r1 - r2 == r1 + ~r2 + 1. + * Thus r1 + ~r2 == r1 - r2 - 1, + * which does not require an extra temporary. + */ + tcg_r1 = load_gpr(ctx, a->r1); + tcg_gen_sub_i64(tmp, tcg_r1, tcg_r2); + tcg_gen_subi_i64(tmp, tmp, 1); + } + save_gpr(ctx, a->t, tmp); + cond_free(&ctx->null_cond); + return true; } + + nullify_over(ctx); tcg_r1 = load_gpr(ctx, a->r1); tcg_r2 = load_gpr(ctx, a->r2); tmp = tcg_temp_new_i64();