From patchwork Mon Aug 30 06:24:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 504304 Delivered-To: patch@linaro.org Received: by 2002:a02:8629:0:0:0:0:0 with SMTP id e38csp1517008jai; Sun, 29 Aug 2021 23:39:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz1FLSFsY7v//yOoXjGzWTa5aK97vNzT5M+HdGxyVETz8+amsvXDI+Vw5oP5VgFKd3rydB4 X-Received: by 2002:a25:7a03:: with SMTP id v3mr21863117ybc.202.1630305580637; Sun, 29 Aug 2021 23:39:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630305580; cv=none; d=google.com; s=arc-20160816; b=iaIUgdqau+zgTtOqZ9jDPQXQiaCzqeCRBuXFl4P3mUQEvNBAxIV3SSJTCRnw8QF7Tl zxLNgudikojXeR8jr4ZEnB6fVjcJ3lKMiEzuitmvxShN2mpkOV6QwK8ocm0obT9L8ljW NcyRQPcnaXICEDfnvsZoz/mHTmpuUa9b3O9rvQmX2L40Yeh711OyYlQLLLZLz4UJLDsE /sHb3Ub/W++PUBPJUX4FqNehtWcUbT0yy0DpoNDmU1QDceTQkJ1OU1TQkHsrTka5HSkL LXyXRYGhuTWtSsDI94HPZnwmAEt5sTzm3K4/srX2S+7oV9CGKur4kHzI0GeVOGMC6x9I tL7g== 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=qbW4VpjE9MbutpbgnWYnm2S01dHzMdGYJQJnh5A4i/Y=; b=XQdS5re2pEZ1YXGNBrInc7YBpL2P7Nmz0FCf5AaUa8R61Rr0pgwPu0AOQZXUVym8Kb g7Z12JPYWQywJePXCodOrbxsevYBNepyi/DMCC6VidIS1SqOmD6L8Upw+VHY3nRt/y4e cUFznN1UGKmDnqjXAw4g5qwaGhG7y7WHWlMnXlnBh/5xjl6Jz13eupg6UENoBhR6k6Ep W1QbBQN+04dwJ9kkd6wZ3ELEo4rs1QljgYrXnYF+1D4ltDUr8QJw8fH44NAuOCvSIZbY ZuSotbcp+TuVkbBq9aIae9aMj5eES2IKOrXWW7mdIt9TDyWor7/oMItG8uSPyYN1Cs7l S+9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lFp62LUZ; 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 d4si14495638ybq.435.2021.08.29.23.39.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 29 Aug 2021 23:39:40 -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=lFp62LUZ; 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]:39954 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mKaxI-0004Nt-2V for patch@linaro.org; Mon, 30 Aug 2021 02:39:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46352) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mKajD-0003yL-TK for qemu-devel@nongnu.org; Mon, 30 Aug 2021 02:25:07 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]:46026) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mKajC-0007XF-B8 for qemu-devel@nongnu.org; Mon, 30 Aug 2021 02:25:07 -0400 Received: by mail-pl1-x62b.google.com with SMTP id d17so7915921plr.12 for ; Sun, 29 Aug 2021 23:25:05 -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=qbW4VpjE9MbutpbgnWYnm2S01dHzMdGYJQJnh5A4i/Y=; b=lFp62LUZ+/Mm3QWL+0vcReiEFOh6vc6ZAmEWKAHVbXCPZIZ85UBIPsjLi3l+clw7my 4C2qx0LVSOw+A9FeQDdwwdG6KNk/FP2FKcl6pxEv7lI0pHxOufHOBA1+XfOX1TZVTh0m kRTsOsHSxuwI5rPT7sLxzIM7CC5f8SglumDxG2TTMr/erOTlkMCBmaSgWAToBfGR9eU/ 9sgbnR6AsnLCf33ieo9DaJoMo2/5uyADGudqnx1iyKRYmqOaa+LSWTU7Ve1EeCi8YBxf Uoqoil5/U/7WTmqBgYIp81B+D0RxujL4xS+m6UZJDLJp1LGV55aEyFZXNlHdwScI7ZII bFUw== 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=qbW4VpjE9MbutpbgnWYnm2S01dHzMdGYJQJnh5A4i/Y=; b=V+BDwRq+dCE3eQz+IADP2G+8gm/0mPJUTQL5QWgeAHBtBcYN9YeO2ushRYWrIB3cQL 73pHRirQabh9OqRalSMH12/v3HMM4zflDp+hTH425ZYN+TAlQ8cedxjiDlXsZdqXa+Eu Ie+y9/U5C8zgAXasXWieRWLtupUL01sz4zIkMoMNtCY1TP3VT6lYHpi+bUtgF+z0Hk6j XXKgDwYYKlwFWCdStrzMWoN9cqdfSujbTh03WmMK/ps7Ir6VOMuyzbS5WPCEsaaup2pZ OAdcS8mRPhlSaeabQssM9ItYyiOZFcMnVoL4rWddGMleP4ZsBmRVhfE8ajY84JZnIEO3 NQ/A== X-Gm-Message-State: AOAM531C1V1ck87gKdVmfzKmwpWjeqteQ1tUgUpQwRyZAbYwKHjVN6EC qr9P7+ty1EI/Bqm+k2TS5QxzUCRLcJX4jg== X-Received: by 2002:a17:902:7882:b0:131:2e12:c928 with SMTP id q2-20020a170902788200b001312e12c928mr20475939pll.74.1630304704917; Sun, 29 Aug 2021 23:25:04 -0700 (PDT) Received: from localhost.localdomain (174-21-72-39.tukw.qwest.net. [174.21.72.39]) by smtp.gmail.com with ESMTPSA id b12sm13942084pff.63.2021.08.29.23.25.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Aug 2021 23:25:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 18/48] tcg/optimize: Split out fold_brcond Date: Sun, 29 Aug 2021 23:24:21 -0700 Message-Id: <20210830062451.639572-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210830062451.639572-1-richard.henderson@linaro.org> References: <20210830062451.639572-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.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" Signed-off-by: Richard Henderson --- tcg/optimize.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) -- 2.25.1 diff --git a/tcg/optimize.c b/tcg/optimize.c index 0ddeaf7e4f..9dfd172a34 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -714,6 +714,22 @@ static bool fold_andc(OptContext *ctx, TCGOp *op) return fold_const2(ctx, op); } +static bool fold_brcond(OptContext *ctx, TCGOp *op) +{ + TCGCond cond = op->args[2]; + int i = do_constant_folding_cond(op->opc, op->args[0], op->args[1], cond); + + if (i == 0) { + tcg_op_remove(ctx->tcg, op); + return true; + } + if (i > 0) { + op->opc = INDEX_op_br; + op->args[0] = op->args[3]; + } + return false; +} + static bool fold_brcond2(OptContext *ctx, TCGOp *op) { TCGCond cond = op->args[4]; @@ -1628,20 +1644,6 @@ void tcg_optimize(TCGContext *s) } break; - CASE_OP_32_64(brcond): - i = do_constant_folding_cond(opc, op->args[0], - op->args[1], op->args[2]); - if (i == 0) { - tcg_op_remove(s, op); - continue; - } else if (i > 0) { - memset(&ctx.temps_used, 0, sizeof(ctx.temps_used)); - op->opc = opc = INDEX_op_br; - op->args[0] = op->args[3]; - break; - } - break; - CASE_OP_32_64(movcond): i = do_constant_folding_cond(opc, op->args[1], op->args[2], op->args[5]); @@ -1724,6 +1726,9 @@ void tcg_optimize(TCGContext *s) CASE_OP_32_64_VEC(andc): done = fold_andc(&ctx, op); break; + CASE_OP_32_64(brcond): + done = fold_brcond(&ctx, op); + break; case INDEX_op_brcond2_i32: done = fold_brcond2(&ctx, op); break;