From patchwork Mon Aug 30 06:24:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 504326 Delivered-To: patch@linaro.org Received: by 2002:a02:8629:0:0:0:0:0 with SMTP id e38csp1526693jai; Sun, 29 Aug 2021 23:59:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJysIDOPdHGAVDdFZjHuvEaipdImn/SCSAkvC+ro7sgU1YpzGzlh5/4bK6urjpEFv8HMOW/Y X-Received: by 2002:a25:9941:: with SMTP id n1mr21518339ybo.247.1630306753087; Sun, 29 Aug 2021 23:59:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630306753; cv=none; d=google.com; s=arc-20160816; b=Ss8XIDGnDUJCUjJl6LCWfxusWX4nstOSaLYiQGEJWfNsbZRk0Y7d35FI2EOOUKtyG9 /hNAhscoIS0hMBzTdUQBDzEjKlVPQ4klWgVb2v9LQeTDSN5njW4e3p/8jD19zBjEagrN 8PtxQ9GxTqKwFmhCi6ovU7BdX4FJSp5V1bC0esIXezusDMsoSzapsLThObMNTQkcVk6v bQBIcniFHHr2Gp5dn5/i/xZNTjhzfT4ilh62T8IBDbQEP1HVLkFzv2NDo6UT0oOg2PSy FcpwZRQyOjVDeYXeRzRknQUy4BlqeloZJrfATUdjNSv6bCGW+gHJKqMz2j+hdf03U6yS t60Q== 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=JMN+jgjbqzyFfx1kKgY9/hqg7NPVZxlqOppkdWbMcfE=; b=m8f/4C3NdTZfPTluJbOSw0gn6/fZn7BAPpYf/cGcSr3pZiPaETJNJ23f/b0cukgQHf QT4eh8wk8iOrsWlETT/PRAZRyKuu37L267aXJgYRXkIsbP90hyeDWCxzN3k/qk8vNicK st9ENmbDHQoxYogPCTvibDrRWOsrZUq34G8yT+0YPdGcfq+Eo65ZogrOiWb9Ax01yZlB hJ70ZIBGR7QgVQXEK5dZ3OI+PjDMYbGw0+cyjVwdehFOfjEpz1rkwCTd9R+UmYGlbWNC Rewk5tXKhClWguaSB/6CSszqDMHPO9Bm9d6G2yCoItmDHpQe32PK+qnrw/FQfo9QO4WC YBmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=T0LZ7+Eo; 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 d63si14574717ybc.384.2021.08.29.23.59.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 29 Aug 2021 23:59: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=T0LZ7+Eo; 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]:34472 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mKbGC-0005AY-In for patch@linaro.org; Mon, 30 Aug 2021 02:59:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46616) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mKajQ-0004Sg-9P for qemu-devel@nongnu.org; Mon, 30 Aug 2021 02:25:22 -0400 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]:51784) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mKajO-0007i5-37 for qemu-devel@nongnu.org; Mon, 30 Aug 2021 02:25:20 -0400 Received: by mail-pj1-x1035.google.com with SMTP id oa17so8765058pjb.1 for ; Sun, 29 Aug 2021 23:25:17 -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=JMN+jgjbqzyFfx1kKgY9/hqg7NPVZxlqOppkdWbMcfE=; b=T0LZ7+Eol6eEgWRp3enpHKJp/eoPHEy9TjGiG5H+DnAFeR50i+zHVMstQu2quUeylw mgreptkcQHXZueqGSNF2eMKzBj3BljwZCpNIXZydtkazfUpXWI/THyY47/ErnzjfsVIx /eK3lNDLYVeUg8mhjXLvRRTmkOKd+KvD4+cP5a0GOd0qTGQUUVLG7ee2bDjbWVTNWGmr 3xfMBIkQsOcRsw1TNsui0Ems1P6rRpaV+xJMBVoEh6y2rW/FTzPYb1BIap29Yehqx2T3 nZvcEFkNPDvz8flJXb7LjzWlWG81Y9nLBNPT/L4gcc56PKW2sp/bDmoyorRQ1e0ZhDD3 bl5w== 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=JMN+jgjbqzyFfx1kKgY9/hqg7NPVZxlqOppkdWbMcfE=; b=BJyZXK4p6V34MXwU+eZj3q6zzhqdADJBnqOVrIWJMw9JQ2cLywdYTBt/FvQ+6FRrQ0 CZi2GLOckhKETDGQH+/fr6SODyl3LYla0WOH9DUYKiMn27JOGn4EhgB7YSIRsMc5MPvS uIZULyRjmGAsShM2VIGyBgjLmq7bTgdFqaK1/6AXoWGQxc97TEKq++PgEbgbH6ThML84 iUZuhSaH3Xr4I78SXV9PrF0uPnGCAwWXn0S+8mvHU3OiMlrkZFLSp8MoBZ/d1cy0DHJl T+SaCHkI1zXqAK5aJRuJmuuDvXWArsp0MknouSQnIP5Fz3F+D/DSHeUVoJDs0y2giIoa iZyQ== X-Gm-Message-State: AOAM532My2mv4+XJmIyyKfCofaJOQQ4qRWWRVwlgMjRhDllRr1Gu6ajj sYW3g4yxAeb+f/jTbHCYUx0ZaXJ2qjGbEg== X-Received: by 2002:a17:90a:44:: with SMTP id 4mr24609943pjb.130.1630304716712; Sun, 29 Aug 2021 23:25:16 -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.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Aug 2021 23:25:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 37/48] tcg/optimize: Split out fold_ix_to_i Date: Sun, 29 Aug 2021 23:24:40 -0700 Message-Id: <20210830062451.639572-38-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::1035; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1035.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" 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 diff --git a/tcg/optimize.c b/tcg/optimize.c index 3b0be1c4e1..69367ddc8d 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) { @@ -1358,6 +1367,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; } @@ -1526,24 +1536,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;