From patchwork Wed Sep 9 00:16:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 249408 Delivered-To: patch@linaro.org Received: by 2002:a92:5b9c:0:0:0:0:0 with SMTP id c28csp5016558ilg; Tue, 8 Sep 2020 17:25:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzcJufslqKV4phm1ajYVq3gX0J1XEBVb0DdGDdBahTpxjgT8dlTGe0UdalWeUk3Wk2oAKws X-Received: by 2002:a25:6a88:: with SMTP id f130mr2160789ybc.411.1599611104936; Tue, 08 Sep 2020 17:25:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599611104; cv=none; d=google.com; s=arc-20160816; b=c2w0G1+q3zyTt1Nwz1pRph20qQ4BHzUr9+Uwv5jOBzrpxkgqfYt/Ww08AqO4MmnAaV odTU0EFlh26PCQ3mfXPelfcg5n7tGBScvcbIgXDVm1g23979gWL86KIFvBkXFYxDXUC2 AMcQiSyxllfhDz22PJYiIY2kzpT7bnz9y+hUzDbs42/rYy90dRBXFiIS6CefyqfJSFaq Zt2lBh+XazamfmqLaModnpyF1McoibPH5xk8LAESc6e5NztU5+IV0oqDxLoxcj63m0fy 89ygy+PE+kw7BeNCD8U3eNAZRVuTRVm+6XXzt7ubYYwoijKOliYMkjKv0GhzPca3KlOg ta2w== 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:to:from :dkim-signature; bh=x+s9W4S8X9df0AJnC/pFDE7SPPgT3/tOf2XSzgDEzSo=; b=NCT3DkIuflO6OULdUI658rGOqi3YpOS7WF7ez1GAw0CqQNIhFLAGDA9R3KcHbnzzaG 1cf0rI5j+qFUxLOhNkIS6lE8KNONjegGiT8pzhb0VGm5w+WQ2lNdWbIeraoA+mjlR4mN zhicBrTBrG/gvasPxb7JTSNNZRKVDBwivVL/sBMGVp4nuKixGTEi5BKwdmxTE2hPUn86 zUsE7uEDuMQpVdm/Ei7VXuvesegGpR2cvULj8qp+HDfmShp4YUZdpeszW97SSzb571Pc X8l7tW/f+ZU187AP8oz4ESsqhxEOAu3tldLLPrVJN9PyEUYaoFLPBV6k2s9IuRYHpn94 1B4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LWrer79b; 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 u15si1128409ybc.228.2020.09.08.17.25.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 08 Sep 2020 17:25:04 -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=LWrer79b; 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]:39490 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kFnv6-0008CI-Bo for patch@linaro.org; Tue, 08 Sep 2020 20:25:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37504) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kFnnY-0008ON-AY for qemu-devel@nongnu.org; Tue, 08 Sep 2020 20:17:16 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:37377) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kFnnW-0002FW-MK for qemu-devel@nongnu.org; Tue, 08 Sep 2020 20:17:15 -0400 Received: by mail-pf1-x441.google.com with SMTP id w7so565013pfi.4 for ; Tue, 08 Sep 2020 17:17:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=x+s9W4S8X9df0AJnC/pFDE7SPPgT3/tOf2XSzgDEzSo=; b=LWrer79bKyuhjmzyncNJWLXkxJGTeDtW71v/dXDkZejqc3re+JH+4+kTrvE4k5vHgs K0Ze/HspxaLKlK9o5Miz/ba11e1YHZQxy6+Fs0p0Row87q9Zuq7Gw/sTVCCPC+yFSZiK UYeBsgdzspNa21PpUTz6Edu6y9ZuR5Jpl8bOosxV3+eNfvRd+pqdOewlW9WXOZ+EWkPU cnfT9tVDZQeqLaMbLbB3Sn9CVS86Wrd1ja6YeU63VJrNoGpKySdiF9bgXDeTWtw6PkWr F7YFWLmtsvfog8NB61c7G48vLCzyihC9bonQ9145xeuaE1GlcJ/6QQGlNDdy62w9+OvH bbQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=x+s9W4S8X9df0AJnC/pFDE7SPPgT3/tOf2XSzgDEzSo=; b=QSndHHKjonAZUOXCwWzd4GAF782xgi4y5vpJgFMOQa+C7oFQct3/JJdbib1x6NO/Nk PrduiQLVuP8o6YlKYs9iYI1Onq28ytpdXEjr/CZUeTEzP5mZPjpQ5WFr89pcxvujjiQT PxiKoyRLxpHqzRIhBDzMz6fy0GM7OTIHaNO/5QvGInHuZdQRcaFfog4U5gB1dS3wocTx K3XovagLSrx6/aXgfMSQmVxeSfErbHF8wazrgLzvI+nw0N5BnDSSTyA5PML+TJ0APh+G kKEaEZhOc2smgkqyjqWSWIERwYClJqUtEt8ytO5jig9BhRpQinEvBXOMD9yUABCBYMAE 56rA== X-Gm-Message-State: AOAM530M1BMpZT0i28kBrKYfgacIN2TUje6MYnfgddaeoFAgqvsMh/l5 Wn9ErujL3pb7fzCD5980ePTx4keQJJ1JxQ== X-Received: by 2002:a17:902:788e:: with SMTP id q14mr1097753pll.140.1599610633108; Tue, 08 Sep 2020 17:17:13 -0700 (PDT) Received: from localhost.localdomain ([71.212.141.89]) by smtp.gmail.com with ESMTPSA id 137sm505437pfu.149.2020.09.08.17.17.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Sep 2020 17:17:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 19/43] tcg/optimize: Improve find_better_copy Date: Tue, 8 Sep 2020 17:16:23 -0700 Message-Id: <20200909001647.532249-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200909001647.532249-1-richard.henderson@linaro.org> References: <20200909001647.532249-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::441; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x441.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: , 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 c0fd65d2e4..bf2c2a3ce5 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)