From patchwork Fri Feb 11 01:30:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 541759 Delivered-To: patch@linaro.org Received: by 2002:ad5:420f:0:0:0:0:0 with SMTP id e15csp2712112imo; Thu, 10 Feb 2022 17:52:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJy73a2KN2EcdwDD3j4gMtFmIEVCTR5BlSTdlevmmZk26vXr++RHeXqQg5r4WEX9wSpAmVJ9 X-Received: by 2002:a25:ac10:: with SMTP id w16mr7096909ybi.24.1644544352749; Thu, 10 Feb 2022 17:52:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644544352; cv=none; d=google.com; s=arc-20160816; b=ovtVad+Nboyb23fkDA05bmFn3zRrmcmuDkc8v8Djm9kX58qpfElHKU2GNE57+LTYRe B8lolua+nbn8bF1eUHvjVcnbY3ONLO8/IP7UWy6C1ANqkOPakyFrV5IFRv87jJENPWMU UA+qBi1N4ySTpGFujkaTmGFEAzbVGPCnbQ7SZLodiJwtJzpdQcP/Zq+IoPR49NbKhoeH rrOat1gTSkpidU+Q9lvwE5GOuRMzVz1Ynshwkir7cyL8P65q2Jw/N3R19vSPt7dIK5wd 4X/z7qMzhmmSt4V0enlq6RMDImbj8TrBVFmXN21WiNT0xQowGkfgieaHyAizq/eWASSH DIbQ== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=i9IlxASYWdMKhZxsDfqVFvhQfn78zXXAMRB1dUwXGuQ=; b=EGhMTakwV+VMIiyDv0Z338WjdwaWyKaX2W2XVDGYOq7BSyFX0PZR/hdLlBbGjxyc5n D5Vv7XNNwC4M3xD2KX+5z3/ssBKb0uLw0Y7OxvEZZoh/nQ+LS7HRMgo/oMw86By+JwZt 05fONJhPv7lyHAVOony4BsQLjfENdIE1MtbpPT0Gx6RnZBskefqw6tf+ic409OCvNEbP gRzUccm/cRLXwCtrw0BQLmwHUkXKQvg6B7u0FH6gR9SBV4KmvLkv5HOY5UIMqHhjbWg1 2J4OY8sBSqbocuMC78aoHoc3H9L8HO67/8xNdywvsrO9CdzdoSdXAxyceOvHlDJGqhok +bwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UlIlf16o; 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 m205si12175661ywm.305.2022.02.10.17.52.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Feb 2022 17:52:32 -0800 (PST) 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=UlIlf16o; 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]:52714 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nIL6u-0003DO-8k for patch@linaro.org; Thu, 10 Feb 2022 20:52:32 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39194) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIKo6-0005Uk-Ig for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:33:06 -0500 Received: from [2607:f8b0:4864:20::434] (port=43562 helo=mail-pf1-x434.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nIKo0-0007Tx-2h for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:33:06 -0500 Received: by mail-pf1-x434.google.com with SMTP id d187so13456910pfa.10 for ; Thu, 10 Feb 2022 17:32:48 -0800 (PST) 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=i9IlxASYWdMKhZxsDfqVFvhQfn78zXXAMRB1dUwXGuQ=; b=UlIlf16oOuJoFR0t7BqFNOP/xcfHzdiK9LLvSkxBjqbjQkUN4WW2ZkWpgx2HlULufB 35ZEQATtQOUmjGSRvmLgBvSWPi+DboIMj53FAJqk4TRC57V5NxBSajW/vek85vlhA0QJ UOlqpp615uwKCaGJeApPHkIgLJX7WjO+9SQh5nDr6krJC5Pezhuvsb1BRh2ds4Q6cfez FGZwztoNYnZEdI5DVOgbtrsxpmezgOUfU4MQFwK5qu65t12oyM2qUNwlMH1lYc+2YAlB Wa0x9WRdflGMXS1O2VqrRsS4YbiYgvTSlFt98XeUXUSeWBzrTcbhTXf8W27WTLsg90cP ipew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=i9IlxASYWdMKhZxsDfqVFvhQfn78zXXAMRB1dUwXGuQ=; b=IhxkulpgfhUsiqws6sMElSoq5bSN88ItMNIiVujT5VWMmtvkZ5dhrhQag8WjCYrNb+ X8HAQP7IXI+02ktdlrxLMRwecywQrBRdNUfeXOgtaXW/jiC9zrDy3s3bxOv6QI0Nzwg0 UnAu1RIjJ0XZvWSkWWUXsn6IkeO+OF5QTrKFSPQvhY1udlgLb0cAPw9HJMPx2XDkMe9Z 9HaRkgr651ZhD1gJGxbQhOprKaeGFU/J7UqHrI1rlvYkdOXCB9S1RIJHI2XRafufmTOz IgVc644Ddxd15BRvLy/YEgzwDpo004p58Hdylx8ndXZIBbJmw5Hg8p/H7lYMbfDHDFkt DiNg== X-Gm-Message-State: AOAM530WyUuLnlruW1BQPZv28e8Aa9choNqCGh9lu9rh2BAOXS4JAofu ZUgcCO48tFMMMPG5aHUc8Q9LXmp09ajG5aja X-Received: by 2002:a62:1ace:: with SMTP id a197mr10230551pfa.63.1644543167626; Thu, 10 Feb 2022 17:32:47 -0800 (PST) Received: from localhost.localdomain ([124.189.222.164]) by smtp.gmail.com with ESMTPSA id h5sm25738788pfi.111.2022.02.10.17.32.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 17:32:47 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 29/34] tcg/sparc: Improve code gen for shifted 32-bit constants Date: Fri, 11 Feb 2022 12:30:54 +1100 Message-Id: <20220211013059.17994-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220211013059.17994-1-richard.henderson@linaro.org> References: <20220211013059.17994-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::434 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::434; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x434.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: peter.maydell@linaro.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We had code for checking for 13 and 21-bit shifted constants, but we can do better and allow 32-bit shifted constants. This is still 2 insns shorter than the full 64-bit sequence. Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/sparc/tcg-target.c.inc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tcg/sparc/tcg-target.c.inc b/tcg/sparc/tcg-target.c.inc index 7a8f20ee9a..ed2f4ecc40 100644 --- a/tcg/sparc/tcg-target.c.inc +++ b/tcg/sparc/tcg-target.c.inc @@ -462,17 +462,17 @@ static void tcg_out_movi_int(TCGContext *s, TCGType type, TCGReg ret, return; } - /* A 21-bit constant, shifted. */ + /* A 32-bit constant, shifted. */ lsb = ctz64(arg); test = (tcg_target_long)arg >> lsb; - if (check_fit_tl(test, 13)) { - tcg_out_movi_imm13(s, ret, test); - tcg_out_arithi(s, ret, ret, lsb, SHIFT_SLLX); - return; - } else if (lsb > 10 && test == extract64(test, 0, 21)) { + if (lsb > 10 && test == extract64(test, 0, 21)) { tcg_out_sethi(s, ret, test << 10); tcg_out_arithi(s, ret, ret, lsb - 10, SHIFT_SLLX); return; + } else if (test == (uint32_t)test || test == (int32_t)test) { + tcg_out_movi_int(s, TCG_TYPE_I64, ret, test, in_prologue, scratch); + tcg_out_arithi(s, ret, ret, lsb, SHIFT_SLLX); + return; } /* A 64-bit constant decomposed into 2 32-bit pieces. */