From patchwork Thu Oct 21 21:05:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 516103 Delivered-To: patch@linaro.org Received: by 2002:ac0:bf50:0:0:0:0:0 with SMTP id o16csp349218imj; Thu, 21 Oct 2021 14:36:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzrRNmPz6rt81osMg4Tdj5wpG6UA+txIo41OOPH+tFPLt6eBxlba1cP5/btRWc+Ol6PXue8 X-Received: by 2002:a4a:bd12:: with SMTP id n18mr6241948oop.69.1634852198438; Thu, 21 Oct 2021 14:36:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634852198; cv=none; d=google.com; s=arc-20160816; b=jEzzlBcYgo0M/RiQU6KvvINe6L5cVoiY5bJx7dV3axLoVuNv6+UIrNG0R5jIyToKN5 dvMpHrMpwZMIlKJlBHpbZyQZyxUyoOd2f76netbbO1AAnTLZBQFlJwMy+S2ZoLr0WaiZ g0yEX9wINN2ZYt+t8IjpJMmJ+J02CkEGuAb0trgwwZG3rBdGuK9sMNJ7Y7OrCFRNklXc OCGDrtyrPE29hG/lxjYDtGa2Z3Udm3BA+ocJma3NAnLtKCTuny8899vzVvIYh6bxoyLi wSoI0CFTUfQxSjVF/kA6oz8gCpXG3fEEX4x+9nlglX8Es13Cf3rBd6pBG5S76uEknVxH jcsg== 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=BUDQu/CJgwa4ODuJqZ+yd21Xfefoe1a81eW46BFAUmA=; b=XsDQJKkkILZu5PU+ttx83ve59le4SJ2WK5t26jsTyHxpVo254OUnXY9Jze1xWjY6FF w6wAwq6GaJNmkfkyV8kr8CxDTN8xXiiszwe/rahIze8QqZwWy/N+FrhNqO2X7EEzvrll EwdaEn1dfcz3aPH/14IksiKddk1Oa2r6KQ6MmczbollUNISa4qu46Vf5smw1qrj0AqZi 5JjzI9XG+NGeR86oHb+28gqBo39QAk11agY0tJvsJRkSznY4ypN1MLHC12657IaqXtHd TUB/MmABt7zLj8mmNpB1SQpydUGcs8VnYDpsmVBs+wzPmd74Qaek1j5zZIXCV+56DcLW QxAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=O1e94xnR; 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=fail (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 z6si7397645otp.289.2021.10.21.14.36.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 Oct 2021 14:36:38 -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=fail header.i=@linaro.org header.s=google header.b=O1e94xnR; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:36628 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mdfjp-0000a5-Oy for patch@linaro.org; Thu, 21 Oct 2021 17:36:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48722) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdfGQ-0007k9-BL for qemu-devel@nongnu.org; Thu, 21 Oct 2021 17:06:14 -0400 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]:35404) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mdfGM-0004m0-1U for qemu-devel@nongnu.org; Thu, 21 Oct 2021 17:06:13 -0400 Received: by mail-pj1-x1032.google.com with SMTP id n11-20020a17090a2bcb00b001a1e7a0a6a6so412815pje.0 for ; Thu, 21 Oct 2021 14:06:09 -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=BUDQu/CJgwa4ODuJqZ+yd21Xfefoe1a81eW46BFAUmA=; b=O1e94xnR0CjTuMfhM3xgHlxxtQVNDySOSWrdE4LMMu+PohZ9+B3DV0ZRYo8wuhwiRN 8utAaFsBArgzDjMqOS6mve7r1W5TqG15kyLrTiHocE/iLwWZ21M9Mbg+1TLOiONi92X8 PSOMXenxgrEf1x/0lvemsottEOtTUFx3GmhbYukFhKdB4nU/tIEeLjOMmdUeP26G6K6H 0p99ZNS1EeEECXod5dR6NTJRSonZVZP3uVsvbN+t7sd8UXPNp56X+pSr9oWtKovL6aHX 1m6Im1YNTQdfMUXDGb6VvcvNk2aD7WZPMvF51QOrWC6mKE/0oY5Uf65GVmBTyHJa4hWG 4N1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BUDQu/CJgwa4ODuJqZ+yd21Xfefoe1a81eW46BFAUmA=; b=xYD0JtM5mMpu46z7RfHk1bcKnETvSLEQpyq3WKqO9pkP7hAekbz3mGhQKnbwg6amJ1 wrTflu83GKQolcKrzFJMs449MOYvA7VDDzCYdk9sCZQPmAVEsMccs9oLiMhuDZK8Ee+D 3eFenHq+j6KNFKDSy/Z061AMdTRC4J+MKgZCfgLk4v10X1sROKk1r2srUvz2E8qxzxT/ 2LbjHMb94rR9MC3wbai+AQk4Y1wApyrv5Yu5g3kqamqcCBvXY+gQhz73P9Lh5VQSBzwg BjLpAkaFZ4g33sqmautch8PLUGOYIIS9d9OXjGvPDsqeMOOreuPAtbW5Yp6Z/ma6higt gRIw== X-Gm-Message-State: AOAM532+Ob2yq6LGMoZWTtxN+avakXtfODGG/mRHJLQ81EUgvKTmoXA6 ykaTa8zZUAG+RtlIb1rvsvAzbN06ssJHCQ== X-Received: by 2002:a17:902:ea0a:b0:13e:8b24:b94 with SMTP id s10-20020a170902ea0a00b0013e8b240b94mr7420082plg.45.1634850368663; Thu, 21 Oct 2021 14:06:08 -0700 (PDT) Received: from localhost.localdomain ([71.212.134.125]) by smtp.gmail.com with ESMTPSA id g7sm5981670pgp.17.2021.10.21.14.06.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Oct 2021 14:06:08 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 37/48] tcg/optimize: Split out fold_ix_to_i Date: Thu, 21 Oct 2021 14:05:28 -0700 Message-Id: <20211021210539.825582-38-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211021210539.825582-1-richard.henderson@linaro.org> References: <20211021210539.825582-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1032; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1032.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: , Cc: luis.pires@eldorado.org.br, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Pull the "op r, 0, b => movi r, 0" optimization into a function, and use it in fold_shift. Signed-off-by: Richard Henderson --- tcg/optimize.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) -- 2.25.1 Reviewed-by: Luis Pires Reviewed-by: Philippe Mathieu-Daudé diff --git a/tcg/optimize.c b/tcg/optimize.c index af26429175..6c1cc3e635 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -731,6 +731,15 @@ static bool fold_to_not(OptContext *ctx, TCGOp *op, int idx) return false; } +/* If the binary operation has first argument @i, fold to @i. */ +static bool fold_ix_to_i(OptContext *ctx, TCGOp *op, uint64_t i) +{ + if (arg_is_const(op->args[1]) && arg_info(op->args[1])->val == i) { + return tcg_opt_gen_movi(ctx, op, op->args[0], i); + } + return false; +} + /* If the binary operation has first argument @i, fold to NOT. */ static bool fold_ix_to_not(OptContext *ctx, TCGOp *op, uint64_t i) { @@ -1364,6 +1373,7 @@ static bool fold_sextract(OptContext *ctx, TCGOp *op) static bool fold_shift(OptContext *ctx, TCGOp *op) { if (fold_const2(ctx, op) || + fold_ix_to_i(ctx, op, 0) || fold_xi_to_x(ctx, op, 0)) { return true; } @@ -1532,24 +1542,6 @@ void tcg_optimize(TCGContext *s) break; } - /* Simplify expressions for "shift/rot r, 0, a => movi r, 0", - and "sub r, 0, a => neg r, a" case. */ - switch (opc) { - CASE_OP_32_64(shl): - CASE_OP_32_64(shr): - CASE_OP_32_64(sar): - CASE_OP_32_64(rotl): - CASE_OP_32_64(rotr): - if (arg_is_const(op->args[1]) - && arg_info(op->args[1])->val == 0) { - tcg_opt_gen_movi(&ctx, op, op->args[0], 0); - continue; - } - break; - default: - break; - } - /* Simplify using known-zero bits. Currently only ops with a single output argument is supported. */ z_mask = -1;