From patchwork Thu Dec 17 14:52:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 344948 Delivered-To: patch@linaro.org Received: by 2002:a17:906:4755:0:0:0:0 with SMTP id j21csp1303097ejs; Thu, 17 Dec 2020 07:11:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJy+XJhqd/Ug9BI2uK4ZuqmYh8EB/q2glR9/zomVM9NfJA4afwYcbuAyOmNnWXRyU+NcZdfT X-Received: by 2002:a25:7e03:: with SMTP id z3mr58268962ybc.251.1608217900881; Thu, 17 Dec 2020 07:11:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608217900; cv=none; d=google.com; s=arc-20160816; b=jrasCcafz8Nct3UQwllExmfkaFYUozuO4SP0pwMN+CeFPsfQbcoou3l34USKg+yaMd lD314evAkiqcwWNanGusb38tftlL67U1QgxQLUcn13F8teGds+4IFKNhGoPZwzCGxYp+ b3ZwAPfi8xaD4glRpkUwK/5gygaBSZMvTET4SDK3Jhnenfla8AqS7JLXzOErnZtcGNiL DDVyUP5JQzNcQUyvMOKniD3x4Pd2+FehqwreAEyC5GuNPRl94zs4AUXllszuQThXE4Xg 6BZar3/icfGHVAS8OIsHRLH71U0J8Nh2ZfEgqhJuRxVI/9d5c92R4LB7igilLOnrCAvV J1rw== 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=r9RYiFGQHVsnTdky7wMyhYvnpEpT+Boqh4/LfVqu7XyBCL8nPntZxDbV066vB7XmX4 AUZ0iWDSbcuOOyHOiBVNC7htDwUan78tWdfAw2wca3C1IWT4PhlaWYvS4BYJN71Db2+2 NXOqZEu/4UwK+JXhxWcUAOB9KG9F9JNf/kU/hI/CBAAqrO9mSTQpT3/akr/Pow2bLCO5 pSRJTu8WTZ7GcOsMmMNm3DCxxSFvABj4Xs8kjX3kLvi4fDyPSGt4fE3ATesvhlS1YCR/ 4a20tY6S8TsegsFJsndS5wFFOLGiNN9swQ6v88ULGICqSTFaBYfWMOYFcZ4iV8ek+Hc3 +bIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Y45N7SZ/"; 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 66si5191891ybo.197.2020.12.17.07.11.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Dec 2020 07:11:40 -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="Y45N7SZ/"; 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]:33294 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kpuwO-00057y-9k for patch@linaro.org; Thu, 17 Dec 2020 10:11:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33216) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kpudu-0003OE-Gc for qemu-devel@nongnu.org; Thu, 17 Dec 2020 09:52:35 -0500 Received: from mail-oi1-x229.google.com ([2607:f8b0:4864:20::229]:41152) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kpudp-0004uv-Bm for qemu-devel@nongnu.org; Thu, 17 Dec 2020 09:52:34 -0500 Received: by mail-oi1-x229.google.com with SMTP id 15so32445855oix.8 for ; Thu, 17 Dec 2020 06:52:28 -0800 (PST) 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=Y45N7SZ/1G1wAVf4ie5dZ3ZzDQFp7nNKDtAwW0L8VeAu0tRCXRI0ojm4Y3xwTdwVZB AE1nBLiz+z6J/DnuU/WeZHo7jTlQcNIXXGE0yc35otugL8GlOz4Xv5DJ4q4eepx29wsg zzA7FfEFuqG/dFNbnCNxDfL5+WM25SOzIBzvLwfOoo+J/HndRB+jXXBr6OXwkRoJD3Ax /bOw+kgJgxV+TPgRHW8KWckuFCEDDVl2tsuh8Uva5F94Zm1iF7A0xRVTqRkkwSWguZtJ j7GSCHOpuAfZmPFWPso7o5ORgCC5OPLUl+I+Tf/oyZbR1SQbtvsLaE717WcyoypYFIDq sIVQ== 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=tt8akvsWd6uNz7vSHsQqG3vt5Ab1sBOSMmyb6j7DUG58oP5Rc1VngN6K6tIo6fbNDz 2RSvzt+6jYmpelFQmLwFPg0TDnqJ+CLqybji8WXzknWO6vjeLu68rnhacHNg7i9rHF35 3wRkz4FyL3Um/BmLfJ0HG8HyrX3ORGLi0lLaOeO6mV2lKzcGkxZl+zqaP3yK4kerVLU1 fQv2hEJeCu+avgwUdfpLaT2hDfIusVY4dYmlUyYfQV4R4mOBFyKwejqDnDHjNrZdYbAe 2iSYOMRx1jo4kobpxLXN9plBVQmekrDFZ5c7bbO2A6Vj9yIkQodmnXYszSfABDKT70FN 8BRw== X-Gm-Message-State: AOAM533rLlcxqkphfOhrgIkF30ABX/ZQxgh0i/Qv9XFRlTZ0HrZC0bJM VlWFcI1XU37CTUP74hndxN0zgu0OtPVKBw+x X-Received: by 2002:aca:cc01:: with SMTP id c1mr5076799oig.18.1608216747597; Thu, 17 Dec 2020 06:52:27 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id x130sm1136342oif.3.2020.12.17.06.52.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Dec 2020 06:52:27 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 09/23] tcg/optimize: Improve find_better_copy Date: Thu, 17 Dec 2020 08:52:01 -0600 Message-Id: <20201217145215.534637-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201217145215.534637-1-richard.henderson@linaro.org> References: <20201217145215.534637-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::229; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x229.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: , 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)