From patchwork Sat Jan 7 07:51:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 640080 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp1177834pvb; Sat, 7 Jan 2023 00:05:26 -0800 (PST) X-Google-Smtp-Source: AMrXdXtBZgUKbG9THvA7QWrfo++poxKXs/F8/smSF0I2kbH7j/Q/vAwA7qOQy+znamINdopenGzs X-Received: by 2002:a0c:d605:0:b0:532:1caa:3402 with SMTP id c5-20020a0cd605000000b005321caa3402mr6170205qvj.12.1673078726692; Sat, 07 Jan 2023 00:05:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673078726; cv=none; d=google.com; s=arc-20160816; b=gWBHO+WFRzqoAq3OdlNaNRhlo+u1XYNZCrOIa13AxmwuIkWbXU976xfLtObdq7EKvF 1gmQ/83iknJU90YLYpYtorohXY52omzuT699kSP7yJJ67sGmxnTeE2/ckDGwjo6n4qw3 VFEyfMsl/g5APXKv4E+HiCOuCIapjhu4cuiHD3of0ntlk3gPKvORv7ihUeIA0kk+0zuW 623rHB//5Ple3TjpLY9X9Z9FNTKsTBZbq9ZzmYTTMkoi3lKk8rHGqbZfgJen4YwwKkWE Nbhba/W4+rO2136brH60upaHpYbRrXF0u+4hU4NjSyoSh7EvV0eQmEHtbsdFRI4K72hb lJxg== 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=KvZtdn0NTISLlVSqR+QnPBDzgwAfic/E3RNSqt0zSa8=; b=NFwb+tnh13ZleS9tdUh1u2AH7XHznnVbiDHOEycSdYU6PwVVbOyBft/SNtczzl4Pix PkaCH41YyyhvW3qzOwdDTo5Y1EYG/ZMeFLr6fHooFy6RhyFYiy/D9JFmIb6wHNVy17/8 VhUVjws6Lk7KNbhyJ0IreNyvEzxaLML92Hq7Bxx4kNw2Ajbfobsl+dI7XxYQE+QRka6g sdcAjbkjAFH3cZZQQbboY0CL/yOZJ5Efx/4GHZc6FSTfm4KtCeV6SvyWDTHAL13dCa9q 3Dd3tp8WLWvN2ByP5iFxIaqJKOVLN5N0o77hH39KzZ3Iont76RCPfZZqORo8ZOfn9C5g rHmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vcaqpOZ9; 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 i17-20020a05620a405100b007055fa9305fsi2102133qko.505.2023.01.07.00.05.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 07 Jan 2023 00:05:26 -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=vcaqpOZ9; 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 1pE3za-0003qA-VI; Sat, 07 Jan 2023 02:51:50 -0500 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 1pE3zX-0003nG-7v for qemu-devel@nongnu.org; Sat, 07 Jan 2023 02:51:47 -0500 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pE3zV-0004Gq-LQ for qemu-devel@nongnu.org; Sat, 07 Jan 2023 02:51:46 -0500 Received: by mail-pl1-x631.google.com with SMTP id p24so4052045plw.11 for ; Fri, 06 Jan 2023 23:51:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=KvZtdn0NTISLlVSqR+QnPBDzgwAfic/E3RNSqt0zSa8=; b=vcaqpOZ9tx6JYPJCBo1hLbxSd7n3Z9r/XHz+bBl0jk76AliaIyIs+C5WEzrtg9+Agl fAsstH7fhX1YgyPEsCZ4DrveMPPKXOA8jxSJIeaqAEImzkYaK3EWRMZlhOb4geHxup41 VxlRaSvOJ8kzo7Y+12O4faf0knTFBozcyT+3U/g34XF/FxJPDpn7kSl0+jek4/R2yuLb IWF4OfR0sCoTLuo7kQMEs/EAMSx/H7bVhk44m4JR0Ugzz87Yo8fUs1pjW23uiCUjtord I5+5srHL3o9fYkbJIRsOi1f2sDU3Xm2r1ykj+gNIQXsFxcX859ShKHrx9zBS/SedqOr1 pMyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=KvZtdn0NTISLlVSqR+QnPBDzgwAfic/E3RNSqt0zSa8=; b=eS2tm6EpYeJ14n/5hqJSE6uOD+CV6PwifWTwK24A6yJCoODC2dixcP+PC/hq0JsH8s LR5wLjwhA4G5wrRUQ2sMnJ8jMtoa4mYh8tYPubhWsGLQOVyzVogQKZJO7RV9HByrM5Jr Blr8M3vs11zRg52/7DMSCKMR51yi8uqxbYCQ9HaONDk98ywWbdZcYq9+tpX3TVCw7/sf rjoGAhdXMzRZhZkWt4FXNlHRUqI3IKky0ZgC9KKwsKRygJ0NJnlLu7wIiLcXoN47lAaM wuf3qDZ6H+pp9PyYwJhEJ8lHNu52Cfc+65ZaaOe+XohryA2xUtKKP2JDBwtQxvXxPMvX 21Qg== X-Gm-Message-State: AFqh2koHdsf7NTF6vj1FdRAgr+IV83mjmW1uk4gB0slUpZp/GKHviJng Y9GNiYSrysBf4xPq9Zb2VcseJw1Yx0FUNISb X-Received: by 2002:a17:90a:db8b:b0:226:a826:9d1a with SMTP id h11-20020a17090adb8b00b00226a8269d1amr13994513pjv.31.1673077904024; Fri, 06 Jan 2023 23:51:44 -0800 (PST) Received: from stoup.. ([2602:47:d48c:8101:9d81:5b04:51d7:acae]) by smtp.gmail.com with ESMTPSA id bj5-20020a17090b088500b00212e5068e17sm1945119pjb.40.2023.01.06.23.51.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Jan 2023 23:51:43 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich Subject: [PULL 26/27] tcg/s390x: Cleanup tcg_out_movi Date: Fri, 6 Jan 2023 23:51:17 -0800 Message-Id: <20230107075118.1814503-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230107075118.1814503-1-richard.henderson@linaro.org> References: <20230107075118.1814503-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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 Merge maybe_out_small_movi, as it no longer has additional users. Use is_const_p{16,32}. Reviewed-by: Ilya Leoshkevich Signed-off-by: Richard Henderson --- tcg/s390x/tcg-target.c.inc | 52 ++++++++++++-------------------------- 1 file changed, 16 insertions(+), 36 deletions(-) diff --git a/tcg/s390x/tcg-target.c.inc b/tcg/s390x/tcg-target.c.inc index 4d113139e5..b72c43e4aa 100644 --- a/tcg/s390x/tcg-target.c.inc +++ b/tcg/s390x/tcg-target.c.inc @@ -874,14 +874,19 @@ static bool tcg_out_mov(TCGContext *s, TCGType type, TCGReg dst, TCGReg src) return true; } -static const S390Opcode lli_insns[4] = { +static const S390Opcode li_insns[4] = { RI_LLILL, RI_LLILH, RI_LLIHL, RI_LLIHH }; +static const S390Opcode lif_insns[2] = { + RIL_LLILF, RIL_LLIHF, +}; -static bool maybe_out_small_movi(TCGContext *s, TCGType type, - TCGReg ret, tcg_target_long sval) +/* load a register with an immediate value */ +static void tcg_out_movi(TCGContext *s, TCGType type, + TCGReg ret, tcg_target_long sval) { tcg_target_ulong uval = sval; + ptrdiff_t pc_off; int i; if (type == TCG_TYPE_I32) { @@ -892,36 +897,13 @@ static bool maybe_out_small_movi(TCGContext *s, TCGType type, /* Try all 32-bit insns that can load it in one go. */ if (sval >= -0x8000 && sval < 0x8000) { tcg_out_insn(s, RI, LGHI, ret, sval); - return true; - } - - for (i = 0; i < 4; i++) { - tcg_target_long mask = 0xffffull << i * 16; - if ((uval & mask) == uval) { - tcg_out_insn_RI(s, lli_insns[i], ret, uval >> i * 16); - return true; - } - } - - return false; -} - -/* load a register with an immediate value */ -static void tcg_out_movi(TCGContext *s, TCGType type, - TCGReg ret, tcg_target_long sval) -{ - tcg_target_ulong uval; - ptrdiff_t pc_off; - - /* Try all 32-bit insns that can load it in one go. */ - if (maybe_out_small_movi(s, type, ret, sval)) { return; } - uval = sval; - if (type == TCG_TYPE_I32) { - uval = (uint32_t)sval; - sval = (int32_t)sval; + i = is_const_p16(uval); + if (i >= 0) { + tcg_out_insn_RI(s, li_insns[i], ret, uval >> (i * 16)); + return; } /* Try all 48-bit insns that can load it in one go. */ @@ -929,12 +911,10 @@ static void tcg_out_movi(TCGContext *s, TCGType type, tcg_out_insn(s, RIL, LGFI, ret, sval); return; } - if (uval <= 0xffffffff) { - tcg_out_insn(s, RIL, LLILF, ret, uval); - return; - } - if ((uval & 0xffffffff) == 0) { - tcg_out_insn(s, RIL, LLIHF, ret, uval >> 32); + + i = is_const_p32(uval); + if (i >= 0) { + tcg_out_insn_RIL(s, lif_insns[i], ret, uval >> (i * 32)); return; }