From patchwork Thu Jan 14 02:16:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 362800 Delivered-To: patch@linaro.org Received: by 2002:a02:ccad:0:0:0:0:0 with SMTP id t13csp68799jap; Wed, 13 Jan 2021 18:25:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJwu0l7Vb0tIKL7lNMKED+x2NCPZE//xON5Y4K40vSRsz+nB56ARtkGwcawX6dAPwZPVsUFr X-Received: by 2002:a25:b4d:: with SMTP id 74mr6976667ybl.189.1610591106056; Wed, 13 Jan 2021 18:25:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610591106; cv=none; d=google.com; s=arc-20160816; b=PtOWDoI7GNSumePiAz2c0AWXDE8v4DJiz6Mwt3TAT+W4amh0oRLXTWBCXd1IfeHLlL vKZ8DID9XlfOzn47Ty4w28wJjisAKRjKWDBLjTfZ1pchN0rEupk5gQz6LmfeCfUX44oo t5QBHbPZKuYIpcn2Qks/YZ+Ce1QVRG27TIurR8YH/uLbnP7A/l6A12P+ItbpNPU6BWqY YKjH2cfYJkkcDbkhdPLvOv/xeAZqWIS60e8NCtGJpnAc+jnt2deTBzies29YpsQAYiW5 +h9faw4LD+yfRyHf/CT/ltF6GH5gOBLIhK2eu0OwF8l4LPgwOSas3x5j70pUvuLGjObQ PQyA== 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=ukQ7RjPHGqGDNjwPl9c9BeoLOp2dRJAKhrKe0DnYWUg=; b=M2Ree3xi52OyBZoV6yHH80TuDSPZxy+HvVZe7ElI+CEg8uBcWoMi7A5az13OMkTbE1 gLMga9sSMZ4iiErexHhXgj4iIz9CtuxnQOnZyY1HbHTt4Yol98x5n5u9m3//Scubpbxb s7mvsmdxLNRRnSnew0jGmemuXHZorpmQtSX8+F+kzk3ksf5ZxxRxt9dNMUil5Wx2G46/ /XamJ5UeX/GTnqviPQb+4L9xnIdvD5dc9VNKIVKN1cZ4IetRJmRqfxjXM2Nfa1PWc9Pb vZOy+P+uUGz0JFDFxPZ9Dwxn9a9L8Zm4NibpD7Cu2T8BIeCeby2t/LQRfi9jI4KVNra8 TInw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gtc4joOe; 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 a17si913141ybj.148.2021.01.13.18.25.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 Jan 2021 18:25:06 -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=gtc4joOe; 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]:58854 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kzsJt-0005Or-H3 for patch@linaro.org; Wed, 13 Jan 2021 21:25:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60208) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzsCP-0003aw-Bi for qemu-devel@nongnu.org; Wed, 13 Jan 2021 21:17:22 -0500 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]:34212) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kzsCI-0003Sp-Rd for qemu-devel@nongnu.org; Wed, 13 Jan 2021 21:17:19 -0500 Received: by mail-pj1-x102e.google.com with SMTP id my11so3198059pjb.1 for ; Wed, 13 Jan 2021 18:17:14 -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=ukQ7RjPHGqGDNjwPl9c9BeoLOp2dRJAKhrKe0DnYWUg=; b=gtc4joOehf/F6/cXYanWxoNiRQghhJuG5QFJHE9gXZopLyzGOtSweO5P9Fv7WuE28H sbXi4/K+CShToreJGXxlaPBqSrPa8CdRo0yFB9dxisLaSOGXc7w/eX/CdcQ45R9DH7yX 0mEIgSAFZfFWM99xT28AOPaQL0+l7T80jMPJAqOGN9KNVy5V1lj6nN98kxi9xZMS6QEd DJfYj1b3XO5hjfNTOgAdjZGwwpSbAj9CHBuBKDLhqplRMC1JpCDuun5LvEb2ZJ6at/as Wlyc7HE9PIUH8ujS/GgNyzOl0gzLEpOPFNc/bPGunSt1kHqjMmz9pVI/jsoErjjWIuRH /IDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ukQ7RjPHGqGDNjwPl9c9BeoLOp2dRJAKhrKe0DnYWUg=; b=pX8RBzQZqmmsX58CyMucVXjVTfiQfZKozwLL71ByN+n0fsVYMYIsaDSCLBut0BapKV KOFKtZ/doSXDcjCthBAJ0oHeQcQWgIQ4P/Shgr8qKKgb3KaECiPetp6vdb7j33e1uCwl 4SlCWcRWzbCsj3F0LrZ6QIt1xeTZIHnzHftsOSR0uyJkPFssQUHepTfNDEkN77KO+fpi lG4Q9gU/q00T32Dwg5VCuhtQX+osglRN6tmh+VpoRN33G/a249un+C3WlGmJmi0guAPl z4b6bpmRRgQxxFBKSTm61+/KRQVzgGYnEYu7zCsNpJTnynzbcmG1zap3jj2CE3AaF1+m QmYw== X-Gm-Message-State: AOAM530Q0HtXX+1W0ryR4OgROMyKQUHdw9Yl468Er7px6OHkDC7ob5r+ fM5nj+p+R/TncLoZ7JsdLSK+NVCobdNGHg== X-Received: by 2002:a17:902:b616:b029:da:fcfd:7568 with SMTP id b22-20020a170902b616b02900dafcfd7568mr5398496pls.35.1610590633409; Wed, 13 Jan 2021 18:17:13 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id i7sm3771687pfc.50.2021.01.13.18.17.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Jan 2021 18:17:12 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 09/24] tcg/optimize: Improve find_better_copy Date: Wed, 13 Jan 2021 16:16:39 -1000 Message-Id: <20210114021654.647242-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210114021654.647242-1-richard.henderson@linaro.org> References: <20210114021654.647242-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102e; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102e.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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Prefer TEMP_CONST over anything else. Signed-off-by: Richard Henderson --- tcg/optimize.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) -- 2.25.1 diff --git a/tcg/optimize.c b/tcg/optimize.c index 16b0aa7229..e42f9c89a8 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -122,31 +122,28 @@ static void init_arg_info(TempOptInfo *infos, static TCGTemp *find_better_copy(TCGContext *s, TCGTemp *ts) { - TCGTemp *i; + TCGTemp *i, *g, *l; - /* If this is already a global, we can't do better. */ - if (ts->kind >= TEMP_GLOBAL) { + /* If this is already readonly, we can't do better. */ + if (temp_readonly(ts)) { return ts; } - /* Search for a global first. */ + g = l = NULL; for (i = ts_info(ts)->next_copy; i != ts; i = ts_info(i)->next_copy) { - if (i->kind >= TEMP_GLOBAL) { + if (temp_readonly(i)) { return i; - } - } - - /* If it is a temp, search for a temp local. */ - if (ts->kind == TEMP_NORMAL) { - for (i = ts_info(ts)->next_copy; i != ts; i = ts_info(i)->next_copy) { - if (i->kind >= TEMP_LOCAL) { - return i; + } else if (i->kind > ts->kind) { + if (i->kind == TEMP_GLOBAL) { + g = i; + } else if (i->kind == TEMP_LOCAL) { + l = i; } } } - /* Failure to find a better representation, return the same temp. */ - return ts; + /* If we didn't find a better representation, return the same temp. */ + return g ? g : l ? l : ts; } static bool ts_are_copies(TCGTemp *ts1, TCGTemp *ts2)