From patchwork Sat Apr 8 03:03:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 671501 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d08:0:0:0:0:0 with SMTP id z8csp611842wrt; Fri, 7 Apr 2023 20:05:53 -0700 (PDT) X-Google-Smtp-Source: AKy350YDrNlaoJ8nDKG2IXe/Jd6RvFSMWzOXkD9wtcf/1UxaAYO03yOddq3y+5cKRtiptVYEbSU0 X-Received: by 2002:a05:622a:1102:b0:3e2:3ae2:790e with SMTP id e2-20020a05622a110200b003e23ae2790emr1209231qty.32.1680923153477; Fri, 07 Apr 2023 20:05:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680923153; cv=none; d=google.com; s=arc-20160816; b=p4BhMeyR00SRsJn26vWPwsul030C728Xe/FkRrS9iXoDk+RhXWzb2HRbtAsiicg8bO 8mkkuR4hneehkbDgYg9CnnHSNYEupuBa0b7LEY6M6aPluNfAva/VHuq0jDS9yVKBMOh/ k7FoPBGnVNvK4RPkiDRPzX1L8n2frtDUns885YrNovxfGAlZ5x312d0sbtTYOm1yLUUi e+zozYfMsqbqaXVUE/iXK3sRSoEhVpM6b5w2cAbIWn5CEAZWTot45naQTiHl0/O4y0E9 xvciCSGAPmwLIw8IPfiP1IhQ9B+YHQhm+HsEMyMj3I5uS1XfGjZmtCdQBOK/FOVdxw2U uDjQ== 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=W3/mfgEEhut6lCtnwnsC8h9ARH2ugsuuRzfccUIm+yY=; b=Td9rR4ppnFay5P2Hc0xothhCGzFJH5+XwRGmyGo+9zFEE7vcVUeWmiDazaT6jWsaNi 8tgSxLAcm+90dNqcHKJhLx5zF/TES30Dxw6KwQSh/oefZSKwBRd4e1Pqm/MW7wzIyCTH vW67hWR2Wl6YHsOTdTWTPFlvRMqTxieYzeC/qd+Jq9JDLtOmU1bWqJ/y7xZBHbFe++bt g2TE4VGizGEGZDZjHXPHqm9Tlg/9b6ATw8TtNiFd5WYROGWQ6NMIHfeBylF35WQC+JVd dEytjWI+Bp03/nMQlm91vVR1t/37qIGhA8P3yC19sym8m60qMtlyOxSYzvpVv6iwzUoF fswA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="NPU/kOF9"; 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 207-20020a3708d8000000b007436f57d322si3642669qki.278.2023.04.07.20.05.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Apr 2023 20:05:53 -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="NPU/kOF9"; 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 1pkysK-0004A4-V7; Fri, 07 Apr 2023 23:04:24 -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 1pkys4-00045q-16 for qemu-devel@nongnu.org; Fri, 07 Apr 2023 23:04:08 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pkys2-0004WC-FJ for qemu-devel@nongnu.org; Fri, 07 Apr 2023 23:04:07 -0400 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1a51ba7fdfcso2440695ad.3 for ; Fri, 07 Apr 2023 20:04:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1680923045; 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=W3/mfgEEhut6lCtnwnsC8h9ARH2ugsuuRzfccUIm+yY=; b=NPU/kOF95RAupGvsmTotsiz3qhWtLOBSASgDXO+AI30lz/6nIFjeeqmBnLPQMegUx6 r99dw5CD931Qkli7uBs8fxMjjpCkCIYMCZt+TWhzbY270Ra6iZy6aqLROygVlyLBzsPS cZ+HN7QV3Fk7xl7It1GQ+OPasvIedjpfOSusghtudtosikMrcWLcIZvQr0qXIOLhcQgc he1xa0MG9XthIyX9zhyQ8ZbLheZzHu/PYeqMOzS0+TLPAyCTQI0RdMlXk0pXgEcq6s8/ tbHFAof6dPT5HhX//8QMn47f/Wj46fW5gV9BaveHNodcHStXGusr7EjUoCrVp1o8Hzv/ dfKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680923045; 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=W3/mfgEEhut6lCtnwnsC8h9ARH2ugsuuRzfccUIm+yY=; b=65L25JfcJdM4pMzIV3eN22DL4ergAD9mz/E8tm4hRGqmZ8RBeKK1Ky5D0RJAEOYuQg 9WAko/Yqf+SfnYJF9aVatt3YVv3uMAmy9Pi+KutMflGa2NNOm9gOnMbeFQnvY7VvgCNH uCm1gJ+4i83F3rz6ffl/XoyLrmCCh7bWb0GBTG8GWjGAhEdWl/vrUTODebIKWSSzL0pS pU3kP+RdJr6TNMTGEG1luY3LklMF+PPnHnBQy8eCFVNU3+vKD29ExzufCiPnABODlkCM jssSGIdiNXiYx6AV1bY41yU45ztOwtFOVwXMJO0HgJlQSswLVMuKm6+c/EshZKYbpHTK qbTQ== X-Gm-Message-State: AAQBX9fe54WmiFLw7IRpzNBxu5m/w63c3Fil6m4MM+imJMM9mUlV/Hr8 J5q69681fi+hVU8ABTq+EGTRir8juuTK0kySGm0= X-Received: by 2002:a62:3802:0:b0:633:5c46:5a68 with SMTP id f2-20020a623802000000b006335c465a68mr138760pfa.10.1680923044977; Fri, 07 Apr 2023 20:04:04 -0700 (PDT) Received: from stoup.. ([2602:ae:1541:f901:8bb4:5a9d:7ab7:b4b8]) by smtp.gmail.com with ESMTPSA id c12-20020aa78e0c000000b0062b5a55835dsm3687025pfr.213.2023.04.07.20.04.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Apr 2023 20:04:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org Subject: [PATCH 05/12] tcg/mips: Split out tcg_out_movi_one Date: Fri, 7 Apr 2023 20:03:52 -0700 Message-Id: <20230408030359.3368868-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230408030359.3368868-1-richard.henderson@linaro.org> References: <20230408030359.3368868-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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 Emit all constants that can be loaded in exactly one insn. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- 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 c2f8d6550b..f0ae418ba6 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -514,20 +514,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 {