From patchwork Mon Aug 30 06:24:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 504289 Delivered-To: patch@linaro.org Received: by 2002:a02:8629:0:0:0:0:0 with SMTP id e38csp1510549jai; Sun, 29 Aug 2021 23:26:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzrxaBBT1tbEmgYrB1MmEq+h18b3WyoDZ0tnOGquUXSMIVG3pC0zfYosMVXwhaqR3/PRNXU X-Received: by 2002:a25:388c:: with SMTP id f134mr20270745yba.209.1630304773282; Sun, 29 Aug 2021 23:26:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630304773; cv=none; d=google.com; s=arc-20160816; b=JwWu/MY8QIF0RAdw8F5Rr5EbX+MLclYfDHcpZMXSGgFKACQom/JcSv6FgU/IBiW8WR p/KCtx82UUOFYS5jBgk4tvZC5g/tb4sA/t7Jjp2aFWPWuQJPXiY0qRVv8VEkeHNxu0Wc 35SMuohb+rDC3aQeIT+RZsKSQLG/9S6vesgFYhQQwRd3upzJ82d2EAi6CCxN39PCgc/9 8MYtZepMzdHUkd18Mp37vQdGT0ca/jUZpgdUzHEh1x1bb9zX1BMxOL2FdwOj+Qpd1Q1y 7onwpR6wjXgt/YSnyPH7CvdfuoaZNhs0ZBAuNSAOI21AnOI3WFeRlrLR20Mxo0btQR+d NPYA== 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=liy2IxUxYk4Q9x1eucfRtbE1W0cpiKHniKE8oZoSFNA=; b=lMNdxgpx/QHH4aTzApjrJyDZAnix9kuwvQJZXmzwCn+72XFlED0szQ1zcMdjtc1yIP 46pPV7gCTHGHYR6ECAtYLguBM+YYqF+Nc1ZUtWNIvs6iOr1uiQpaoOZSYxlcTGHeEcgK O0rmvVOouuWD7grgFsjWqL73TL9tjwog2MiY1DTo5DwlOxpiMJnXWtcCf1SnqjeOTAl2 e9cvZP593rHChAvBFKG6TuykP2YW5bRtEOurh19uziNonVotiISTm3+W9Xj270Wi7a9Z dHVR9EpABnlrWV7+xHX/9/wdFtMUCZd4yEPPePf85XugapCoy10BJNtOVqLJFjsn6obj /Mzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IKnLndzd; 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 n72si13052466ybg.294.2021.08.29.23.26.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 29 Aug 2021 23:26:13 -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=IKnLndzd; 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]:59482 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mKakG-0003qk-Ol for patch@linaro.org; Mon, 30 Aug 2021 02:26:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46266) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mKajA-0003lT-2i for qemu-devel@nongnu.org; Mon, 30 Aug 2021 02:25:04 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]:42988) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mKaj8-0007Tr-C0 for qemu-devel@nongnu.org; Mon, 30 Aug 2021 02:25:03 -0400 Received: by mail-pl1-x62a.google.com with SMTP id n4so834375plh.9 for ; Sun, 29 Aug 2021 23:25:01 -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=liy2IxUxYk4Q9x1eucfRtbE1W0cpiKHniKE8oZoSFNA=; b=IKnLndzdedR5YHvGL6RJon0e+RknnS6zFHiNQNUaSNBHxNMNTtQhSaGs09ZcaY6Rgo jssl4sS5LfhuriRM7DxhrI3mZntCq9hgF9T+RBezoYwdMNvuZwaCMnnx5JWOjMgfFZHq J88vvG5TEWJYw49L551rRRgfW49qhAQgw/luNqwicZx/BN7gloMSB5U+3kqM/4oefimb NQKo58UJySmHFglKepOhWg3mg7bZZivN/9CUVTOCrqG9WUcKM7Vn+M1iXVOCYB45zRNV gosyrPv6DTwm2VkHVnC3Xk70FYo8qL8rqh/jiEUxFZZg8G8d8SjBjyQ0Ey0GjbROoAHU /7fA== 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=liy2IxUxYk4Q9x1eucfRtbE1W0cpiKHniKE8oZoSFNA=; b=DqK3fGbPbxomu8ir1bW6PUz4ccJ7TuQARAOnSlQQheZyL/+wy+cQ5owymPRxb314VQ YlemPa/ryS0s1PGUveT77MLe+zVTYePZ2YOcACeF+nE56nuH5n6zxHuZEajKMPK4536f 7/61B6BZoh2CBM6ekTi+aL8IXy/BJUQRroFxJ2a6LSpwWtG5BQ6oOI7lK4qWRuIOCRvn 1/5I5c1Vbsiqho0heK4V/0d1WzeJaMBP+3+c1cG1fHUwPimrkjyBfcwi2UkYfnAIBAo4 52EWL8QTgWai4X9q0j2ksndHQvJIFg+HLw9FRGeQcyc7UxC6HGyyUntTUm2y4TG8lbcV ECZQ== X-Gm-Message-State: AOAM533bYyLw3QHTbAgfgKketRzBKIYpZb/5a00KaHkJAHJ9sVwKR8oC ALLcwyh3E6dt2S9dQgcIbtqUFQ3QWvYMpA== X-Received: by 2002:a17:902:7803:b0:138:c171:c1a4 with SMTP id p3-20020a170902780300b00138c171c1a4mr7006897pll.48.1630304700960; Sun, 29 Aug 2021 23:25:00 -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.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Aug 2021 23:25:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 12/48] tcg/optimize: Split out finish_folding Date: Sun, 29 Aug 2021 23:24:15 -0700 Message-Id: <20210830062451.639572-13-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::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.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" Copy z_mask into OptContext, for writeback to the first output within the new function. Signed-off-by: Richard Henderson --- tcg/optimize.c | 49 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 16 deletions(-) -- 2.25.1 diff --git a/tcg/optimize.c b/tcg/optimize.c index c4559d32be..d202515369 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -48,6 +48,9 @@ typedef struct OptContext { TCGContext *tcg; TCGOp *prev_mb; TCGTempSet temps_used; + + /* In flight values from optimization. */ + uint64_t z_mask; } OptContext; static inline TempOptInfo *ts_info(TCGTemp *ts) @@ -629,6 +632,34 @@ static void copy_propagate(OptContext *ctx, TCGOp *op, } } +static void finish_folding(OptContext *ctx, TCGOp *op) +{ + const TCGOpDef *def = &tcg_op_defs[op->opc]; + int i, nb_oargs; + + /* + * For an opcode that ends a BB, reset all temp data. + * We do no cross-BB optimization. + */ + if (def->flags & TCG_OPF_BB_END) { + memset(&ctx->temps_used, 0, sizeof(ctx->temps_used)); + ctx->prev_mb = NULL; + return; + } + + nb_oargs = def->nb_oargs; + for (i = 0; i < nb_oargs; i++) { + reset_temp(op->args[i]); + /* + * Save the corresponding known-zero bits mask for the + * first output argument (only one supported so far). + */ + if (i == 0) { + arg_info(op->args[i])->z_mask = ctx->z_mask; + } + } +} + static bool fold_call(OptContext *ctx, TCGOp *op) { TCGContext *s = ctx->tcg; @@ -1122,6 +1153,7 @@ void tcg_optimize(TCGContext *s) partmask &= 0xffffffffu; affected &= 0xffffffffu; } + ctx.z_mask = z_mask; if (partmask == 0) { tcg_opt_gen_movi(&ctx, op, op->args[0], 0); @@ -1570,22 +1602,7 @@ void tcg_optimize(TCGContext *s) break; } - /* Some of the folding above can change opc. */ - opc = op->opc; - def = &tcg_op_defs[opc]; - if (def->flags & TCG_OPF_BB_END) { - memset(&ctx.temps_used, 0, sizeof(ctx.temps_used)); - } else { - int nb_oargs = def->nb_oargs; - for (i = 0; i < nb_oargs; i++) { - reset_temp(op->args[i]); - /* Save the corresponding known-zero bits mask for the - first output argument (only one supported so far). */ - if (i == 0) { - arg_info(op->args[i])->z_mask = z_mask; - } - } - } + finish_folding(&ctx, op); /* Eliminate duplicate and redundant fence instructions. */ if (ctx.prev_mb) {