From patchwork Sat Jan 8 06:36:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 530699 Delivered-To: patch@linaro.org Received: by 2002:ad5:544f:0:0:0:0:0 with SMTP id a15csp993835imp; Fri, 7 Jan 2022 23:49:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJyKr4u1zxaErbv4nFAn0uXhMEUqSNVc3GwKxAqEfDtahOY8MJaruQt5gNHgNBYuMmCTDwkk X-Received: by 2002:a5b:94b:: with SMTP id x11mr65792672ybq.344.1641628183227; Fri, 07 Jan 2022 23:49:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1641628183; cv=none; d=google.com; s=arc-20160816; b=0/+E4dPYjI4IhOcos3k4ZXNYuQaW/0K5i0w0fJgK3qb6Q5qN4Yz7fJn+meX/8PZ/xG bKqqQ/dI2k/UWiZScQVa+OwmBteWfgmCr9fLgg/m3Surtm47plGHlJ3Zx/V3h3swmaN0 61P/GFDN18DbMR+V7WTUn+v9ZkXT9FcfHJKa19noq7sv+n7FQ9eU9gZSOvdX9m7vfUdQ PZb+ZLrAPIJ1oyBy6t3U5ZexKmBSwFz+zFAbTBNWbf25k+PuQWWsfg7VUpDYpncdxUt2 Z7fEQt/8ho2TDQ8xjT3g8Wuck2sX+SKt75SqBjGSaD2/7ROkv7f+uYclVhMP3Q6GYHqM y6xw== 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=MZajHEilU6k0lLPYYDZNQ8jEdB70Bcd5oTv/nQtoSnU=; b=dWtVSpdmykV6Y1a8i2FtXa2rEwA8Cgru9v1knp4LMz0v/WclcdYtZzPAAVDR9pXdEI Qh511yunOSJVajoOcCn4ptFQN26HJSDYw7sAxyP4FbOmi3iTjxk44yFfOABf8DTkMd1O /P9Iz5uf8xcd03oFggNnt9cRHhjv23pTRA1Qy3Q3lcAmxjGUrik6IUPnXeXtKkRQM7RC YO2HleQ61aRMs4ISniZ02WRgtFLBVICjEr9cfHefNQeINReKo5ESG4cav1GPxbO/l2iN 42mpIe3cBWknwPhR2+YrRPMg94rs0jEnwyHjhYGU1ULQM8nKYBRZ6Yff8eg/MQMFlSvb 7frQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=h9tD3gqY; 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=fail (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 n62si750319ybc.165.2022.01.07.23.49.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Jan 2022 23:49:43 -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=fail header.i=@linaro.org header.s=google header.b=h9tD3gqY; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:42458 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n66Tu-0007F4-LD for patch@linaro.org; Sat, 08 Jan 2022 02:49:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58186) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n65Lf-0005i8-4B for qemu-devel@nongnu.org; Sat, 08 Jan 2022 01:37:09 -0500 Received: from [2607:f8b0:4864:20::533] (port=43645 helo=mail-pg1-x533.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n65Lc-00047o-4G for qemu-devel@nongnu.org; Sat, 08 Jan 2022 01:37:06 -0500 Received: by mail-pg1-x533.google.com with SMTP id 8so7660251pgc.10 for ; Fri, 07 Jan 2022 22:36:57 -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=MZajHEilU6k0lLPYYDZNQ8jEdB70Bcd5oTv/nQtoSnU=; b=h9tD3gqY/ZsxBj1V75fRpJ4CVnPcEk+8dJXEKUnzgHHS+QG+0JoLJxup6VZYZlZeUP 8HTb/UlQIE4wT3vMQOZC9Z+pCnqcgUzJd4mwf/GeGWyhjLVXJ1enrFy3evWrSrUAEPdl T8G6lWw0mR2wPhjPWxv4BmZ4e/NVEfzjfY2C+nokqr0WII0MFiHfkZ8iKexbK+4VlMbg CSYrxlSEVczRLUFaWhLSGTBvneLXjEg3StqYM0t2kcSpmpU8NNqnscYEXTg9rtnBFc01 OGxSch+IKR1y0Act55L7uQJnnuoanoZ/dmrCqmfMBjsqwNLsPq//pp9tqNxP9vZnmfFO GnVQ== 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=MZajHEilU6k0lLPYYDZNQ8jEdB70Bcd5oTv/nQtoSnU=; b=Cp/qAttlZtggQvG8UIiGrxKa8fZCI8hj1maw6sJPXgH6+7t2l1aWU9UUyVjxfGp6D9 EcBNTObnvY0dgdaglCKCqoIQ6mtXyoOohxxIdbPe/BE/81Dl+bqfiWMnvZlToNswvCsn J7q7+8mKKDdm6yVH2prmgRAIF6/ffhgIXPiHPYa4e99qlpgnuwPmKJ4CEk2h/ltfgpDb T+2kjs7/g7jiIDSS0BzVbNpK/TFY9iCrHEH2JZK2G5d5KLmOOLPD3fnT2uPpW9ewklpx +fwNyx6Zxv0Ot1+S7xkhXivrq6gu9Qfo7aek13cnzJRgUpTCMHDyZ2Lm4yGG7Wyx0L4+ rHrw== X-Gm-Message-State: AOAM530C6CQyGd2ueUODl62YsQPlyQP3SwK2HVOAu3j1Wyr1cAlJqvdp 9c8Yj9e5LCmPOsmeO72camM5c05sn0IIQg== X-Received: by 2002:a63:b247:: with SMTP id t7mr13164194pgo.164.1641623816390; Fri, 07 Jan 2022 22:36:56 -0800 (PST) Received: from localhost.localdomain (174-21-75-75.tukw.qwest.net. [174.21.75.75]) by smtp.gmail.com with ESMTPSA id z4sm840954pfh.215.2022.01.07.22.36.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 22:36:55 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 07/12] tcg/mips: Split out tcg_out_movi_one Date: Fri, 7 Jan 2022 22:36:39 -0800 Message-Id: <20220108063644.478043-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220108063644.478043-1-richard.henderson@linaro.org> References: <20220108063644.478043-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::533 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::533; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x533.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, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: f4bug@amsat.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Emit all constants that can be loaded in exactly one insn. Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.c.inc | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index 76fb1dada0..8741fdd49c 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -524,20 +524,34 @@ static bool tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg) return true; } +static bool tcg_out_movi_one(TCGContext *s, TCGReg ret, tcg_target_long arg) +{ + if (arg == (int16_t)arg) { + tcg_out_opc_imm(s, OPC_ADDIU, ret, TCG_REG_ZERO, arg); + return true; + } + if (arg == (uint16_t)arg) { + tcg_out_opc_imm(s, OPC_ORI, ret, TCG_REG_ZERO, arg); + return true; + } + if (arg == (int32_t)arg && (arg & 0xffff) == 0) { + tcg_out_opc_imm(s, OPC_LUI, ret, TCG_REG_ZERO, arg >> 16); + return true; + } + return false; +} + static void tcg_out_movi(TCGContext *s, TCGType type, TCGReg ret, tcg_target_long arg) { if (TCG_TARGET_REG_BITS == 64 && type == TCG_TYPE_I32) { arg = (int32_t)arg; } - if (arg == (int16_t)arg) { - tcg_out_opc_imm(s, OPC_ADDIU, ret, TCG_REG_ZERO, arg); - return; - } - if (arg == (uint16_t)arg) { - tcg_out_opc_imm(s, OPC_ORI, ret, TCG_REG_ZERO, arg); + + if (tcg_out_movi_one(s, ret, arg)) { return; } + if (TCG_TARGET_REG_BITS == 32 || arg == (int32_t)arg) { tcg_out_opc_imm(s, OPC_LUI, ret, TCG_REG_ZERO, arg >> 16); } else {