From patchwork Tue Jun 2 17:01:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 187381 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp4145106ilb; Tue, 2 Jun 2020 10:03:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxKUnqF/TaDFPOoYJQKk0woeyiO7kZSktVCcHmPZeNKDeQv96TM/jAu4dRAHNgIBx0VTDAc X-Received: by 2002:a25:2582:: with SMTP id l124mr22919891ybl.59.1591117399734; Tue, 02 Jun 2020 10:03:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591117399; cv=none; d=google.com; s=arc-20160816; b=AmGNdxEyUEeM4/qSluyz+mZgmaTBH5WyDzcvBaID3QDFY0FdSXdbF3F4UlivOJywdZ 9/9VHx/05YpJNFiA+hwn/1hXqRH4lOtSsB3LAH5EHCZZUEwBLkazUmWnS2fYounm3A93 sNLtGN0bQdmNtjWMbMBig6Izwa/ZEb+FawzOY9t3QO3G9TDI5iIdi16S8ylvjE2Kgjg4 jGdPfUFUi9VNNL0fMm+a9UyIZAbmpszfDZOaMDG9de4BD0GVVlDNdS2XwOK+PFl16wTV IyHwkfdXLOBfVpmPSBo1kiydbCFmfWshxPWWw0TJKBkLSusanx7MA71jSz1E52vy+4FM B7jw== 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=tHqpToSLuNmT3+mxdztxkjY6kBf+OhopPIY/mAzI0FM=; b=LIz3Hy/VjQ3xzMkfe4MDWDxT/8imOPMQgnk47Pwk+1xX0r7Zo71HpZI8q0rMiQuN7t 4RHFedyOEPsCIl+HQXE7gGE2cGCeciASep5P7MwPnt6YEEF2/6FQpAMC0gUFFI6gwByT GANbVyqwgcac4QZye8b+ai5HZaCF28URW5CVYvkzUmwuwIZp9x+tfraDDXyb1aDs1xWL ngxX+jQ0++Pdc51n0DL3mdehWCaCvdS4moDGpeJKox4+uNZT6aIzIgTNOg1V5otOaiCF mHlchi9CSoPhDSxnFKbLXtSqpH2KrdEn+4Wc83TL1ZYXU9aJdVQ7WrBOcWDS0D0DW+kt 4tBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zWXRad9l; 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 g15si2801082ybe.188.2020.06.02.10.03.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jun 2020 10:03:19 -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=zWXRad9l; 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]:44456 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jgAJr-00075g-52 for patch@linaro.org; Tue, 02 Jun 2020 13:03:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39824) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jgAIk-0005wT-6P for qemu-devel@nongnu.org; Tue, 02 Jun 2020 13:02:10 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:39357) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jgAIi-0007R2-Qv for qemu-devel@nongnu.org; Tue, 02 Jun 2020 13:02:09 -0400 Received: by mail-pl1-x641.google.com with SMTP id v24so1579696plo.6 for ; Tue, 02 Jun 2020 10:02:08 -0700 (PDT) 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=tHqpToSLuNmT3+mxdztxkjY6kBf+OhopPIY/mAzI0FM=; b=zWXRad9lLOfYB1kXttHNm+JcpktLPnPGpwp7jC0FwNZQCg6PRYkS/OIVgOKccBA2TM /B3USpHFUcUsyinpJiow+8rOYAwHUbDr0Kud7Ec3k6gZS6qdKFZoUcZn4ptlBgxUdB7W G4olbpY4UX7ECn4Cn4SAhG56tycAYLDCdztHq+w4kDvn5QknpsGq/VPBwo+utQNttTwv HvL1uKdBB6QEUi0MZkegsskymKLBSe4rcdMvLZ0OBL3FH4/bwyQ+0sSrXdBPlUT2jCo+ avA56rJnHa07OjSF05fUoGSlAJKy/WbsLlkm3SW3oV3ehkBE3RIu3Rn5cbiCKuHG1K86 O8kQ== 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=tHqpToSLuNmT3+mxdztxkjY6kBf+OhopPIY/mAzI0FM=; b=NQFBf2cJmqAPtL6+9fwPI33WfWDniJiincnKqoa9pEPcxEpMp8jzpR7ftUd4EUG1hb o/iIQzqmTXcPKV4OkLuW6nF3QR9kn2kqW2sDM29VKpZI2g/YmCpv/Lis7Tg3Kto1kIlJ AUferlV8GEIYUoZ37uooOUgfCJ2pZGHcH4uqz1iIZljI9RSSiGQFEmflgWx9rpU/K14u 5tyGtcYe0Ky4Stw0gdREz0Euv8QuABIoieFm5yXtopQzWYyOCPfIYnb8njQJNmTb0BdI pudmBGjKHMY6vmAKR9INEqaAEtx42LTvM73h7oHP7CooGfYAGI0i7mPF+htdFVjLstRC v9aA== X-Gm-Message-State: AOAM530079jYTOFzhNDxuGs9fI6fG7H/shnAfdiYVAbcHztXZH5SJiin jzqboaJJaeTf5rE+Si6R+Q4jSf6pVcA= X-Received: by 2002:a17:902:c3d3:: with SMTP id j19mr26285210plj.47.1591117326991; Tue, 02 Jun 2020 10:02:06 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id h11sm2723630pjk.20.2020.06.02.10.02.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2020 10:02:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 10/12] tcg: Improve move ops in liveness_pass_2 Date: Tue, 2 Jun 2020 10:01:49 -0700 Message-Id: <20200602170151.321389-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200602170151.321389-1-richard.henderson@linaro.org> References: <20200602170151.321389-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::641; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x641.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_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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" If the output of the move is dead, then the last use is in the store. If we propagate the input to the store, then we can remove the move opcode entirely. Signed-off-by: Richard Henderson --- tcg/tcg.c | 78 +++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 56 insertions(+), 22 deletions(-) -- 2.25.1 diff --git a/tcg/tcg.c b/tcg/tcg.c index 97558ec068..1aa6cb47f2 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -2982,34 +2982,68 @@ static bool liveness_pass_2(TCGContext *s) } /* Outputs become available. */ - for (i = 0; i < nb_oargs; i++) { - arg_ts = arg_temp(op->args[i]); + if (opc == INDEX_op_mov_i32 || opc == INDEX_op_mov_i64) { + arg_ts = arg_temp(op->args[0]); dir_ts = arg_ts->state_ptr; - if (!dir_ts) { - continue; + if (dir_ts) { + op->args[0] = temp_arg(dir_ts); + changes = true; + + /* The output is now live and modified. */ + arg_ts->state = 0; + + if (NEED_SYNC_ARG(0)) { + TCGOpcode sopc = (arg_ts->type == TCG_TYPE_I32 + ? INDEX_op_st_i32 + : INDEX_op_st_i64); + TCGOp *sop = tcg_op_insert_after(s, op, sopc); + TCGTemp *out_ts = dir_ts; + + if (IS_DEAD_ARG(0)) { + out_ts = arg_temp(op->args[1]); + arg_ts->state = TS_DEAD; + tcg_op_remove(s, op); + } else { + arg_ts->state = TS_MEM; + } + + sop->args[0] = temp_arg(out_ts); + sop->args[1] = temp_arg(arg_ts->mem_base); + sop->args[2] = arg_ts->mem_offset; + } else { + tcg_debug_assert(!IS_DEAD_ARG(0)); + } } - op->args[i] = temp_arg(dir_ts); - changes = true; + } else { + for (i = 0; i < nb_oargs; i++) { + arg_ts = arg_temp(op->args[i]); + dir_ts = arg_ts->state_ptr; + if (!dir_ts) { + continue; + } + op->args[i] = temp_arg(dir_ts); + changes = true; - /* The output is now live and modified. */ - arg_ts->state = 0; + /* The output is now live and modified. */ + arg_ts->state = 0; - /* Sync outputs upon their last write. */ - if (NEED_SYNC_ARG(i)) { - TCGOpcode sopc = (arg_ts->type == TCG_TYPE_I32 - ? INDEX_op_st_i32 - : INDEX_op_st_i64); - TCGOp *sop = tcg_op_insert_after(s, op, sopc); + /* Sync outputs upon their last write. */ + if (NEED_SYNC_ARG(i)) { + TCGOpcode sopc = (arg_ts->type == TCG_TYPE_I32 + ? INDEX_op_st_i32 + : INDEX_op_st_i64); + TCGOp *sop = tcg_op_insert_after(s, op, sopc); - sop->args[0] = temp_arg(dir_ts); - sop->args[1] = temp_arg(arg_ts->mem_base); - sop->args[2] = arg_ts->mem_offset; + sop->args[0] = temp_arg(dir_ts); + sop->args[1] = temp_arg(arg_ts->mem_base); + sop->args[2] = arg_ts->mem_offset; - arg_ts->state = TS_MEM; - } - /* Drop outputs that are dead. */ - if (IS_DEAD_ARG(i)) { - arg_ts->state = TS_DEAD; + arg_ts->state = TS_MEM; + } + /* Drop outputs that are dead. */ + if (IS_DEAD_ARG(i)) { + arg_ts->state = TS_DEAD; + } } } }