From patchwork Thu Oct 21 21:05:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 516114 Delivered-To: patch@linaro.org Received: by 2002:ac0:bf50:0:0:0:0:0 with SMTP id o16csp359628imj; Thu, 21 Oct 2021 14:51:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwOceUjyHBjkluhUOQtHs1Kjb8neDKAg4/7eFCG7IBbVjIr9/x0AKEbSLFLTYmgC5cH/K0S X-Received: by 2002:a05:6808:10ca:: with SMTP id s10mr6183229ois.62.1634853067030; Thu, 21 Oct 2021 14:51:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634853067; cv=none; d=google.com; s=arc-20160816; b=CIDnoP8UokhO0fkBajVe7B6LW3LSrpVZWDMXI/v7oEO5wI1/+ckzTkq3723nNQlOcV Wlnvj8sIDE5uAOzjrw1Qqk66RDFjpodnS2YYLI4jBP8BjP0psxibmU4N/rufkJ/h1LEz G96jc0qZxXYdrEDw5GqFD7r1ZD82hWPZr8WCfXh3gqUz0yTpbjLx3Eu6Tak3rdmX35kb F65nEl6lsrRcPLO07FJIkHM0QCwwIk+l+4MC+WXMqA/p/sFgDBCPB4e9fUQFCVpNn9HK ck8ceqX76MwICiEUZvj2gkl5KugMd4Q0oRP69SYQP+sNAoyr5sJGC/jLvWJGJ0POu9vj rd6w== 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=GU366PG39bQrvgFIMFuSB4WuW9ukWUVOmma2KCQGLxs=; b=n+eIPJ3kwa/XyKjxW8v54EBNmaw6hShq2g470U+TJIkuVZIjAfbfPb4YNMJeYWyk1B T4DfPnJ8cEqnqvxb5ELuUIvDYHRmQn218ecrWyjSf6R1MT0uEhILS8LHex7SF1oAVvMt m5/y3sgOXCUFB/AMG7ERbfVVzz66XzFEUnPjRhhi0mYLZiIu5WGhVsVJaPqlL7d9PGnK 18nho2uEd1SLkwIyCYvFrvasIa+tWh6A2Is+VrwzP1ZKwpkwHctBf5b8QKNJwq5YNTSD Zcm/zJP6HjUqG8SPf/exlqvMpCwnHnuAv4fjj0XD0F3qXUvwVB80DeKuFcji2c2ZLQ/m 90jQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ex6wbFjj; 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 o7si9396314oiw.306.2021.10.21.14.51.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 Oct 2021 14:51:07 -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=ex6wbFjj; 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]:43840 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mdfxq-0007rd-BP for patch@linaro.org; Thu, 21 Oct 2021 17:51:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49302) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdfJQ-00044F-0D for qemu-devel@nongnu.org; Thu, 21 Oct 2021 17:09:20 -0400 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]:33400) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mdfJM-00007w-PW for qemu-devel@nongnu.org; Thu, 21 Oct 2021 17:09:19 -0400 Received: by mail-pl1-x629.google.com with SMTP id y4so1329725plb.0 for ; Thu, 21 Oct 2021 14:09:16 -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=GU366PG39bQrvgFIMFuSB4WuW9ukWUVOmma2KCQGLxs=; b=ex6wbFjju0ycdbqer6JnDsF7MVWbKuTFK+RuIn4y03Pq5YgYW9YDD72g5uKtrMrNdX leO95WblEl6EufJObBTyiGLdt3BE9kb3FUo1dMGjiGAZ2/NXKGC/gYdBaJlUkAWTLS/m 0fWLkdCECX30TxRcoW5OGOdPKSo3LuiF72UTX3wG39qcmEcMVki7JPEJIa84CzXE8zSN Y1vYno7nMxv3ytlbJieJ+RPfyvxg5cHpI6o5fRBYYewIZFkwr5EJ9NkOPp03ztp25zpa hfLvQiDZSmdBeyHgaME/LfjPL/nHlFd9trJzJUB5rc3+y6eqrqBtc6VZobpGQ7UUeU1J 8UpA== 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=GU366PG39bQrvgFIMFuSB4WuW9ukWUVOmma2KCQGLxs=; b=b2k+lCfg0NrpRW9S6DKDCw3ht1bUlUkfXwoGe59PSGKalNbuVnlQZhxdcZYSz5nHTJ 2+MXp8yLAR2bkh0ysYZ8aRSITGnXY2dJzQuJ+t+fBty3wTkW7Ryf2AgAAt5Ph4wbxeO/ VCTbcO4sVAYWLS3kVxvZFy73bbYcO5B5zsi97BUXF70RC8YQhpf9vC+HyTPtRrkzZkmM f2Wc6fd93484vvfn9WoYfGVeB8egvMGH4ZcotXzx0DWX2FSD1kB/80usrnpz6ZnugBp3 c+cKoW3S18gqLpncr6Gh6HwExur6965Lk/+/GlzlUgM8nOPgk82V3Hz+tDVZ0Qym5Fmq dIUA== X-Gm-Message-State: AOAM532O2jiaB/WRNjrNAM8O25+jaCRgpmo8+iaTfQZpcTPsoa6+zbTI 9fVO7JUobfmkIDR+SUI4aCbE1NPjrbCbFQ== X-Received: by 2002:a17:902:e848:b0:13e:f908:155a with SMTP id t8-20020a170902e84800b0013ef908155amr7469256plg.13.1634850555330; Thu, 21 Oct 2021 14:09:15 -0700 (PDT) Received: from localhost.localdomain ([71.212.134.125]) by smtp.gmail.com with ESMTPSA id i5sm6258856pgo.36.2021.10.21.14.09.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Oct 2021 14:09:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 45/48] tcg/optimize: Propagate sign info for logical operations Date: Thu, 21 Oct 2021 14:05:36 -0700 Message-Id: <20211021210539.825582-46-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::629; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x629.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, =?utf-8?q?Philippe?= =?utf-8?q?_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Sign repetitions are perforce all identical, whether they are 1 or 0. Bitwise operations preserve the relative quantity of the repetitions. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/optimize.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) -- 2.25.1 Reviewed-by: Alex Bennée diff --git a/tcg/optimize.c b/tcg/optimize.c index cf3c9d6b12..d08cf7e4eb 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -953,6 +953,13 @@ static bool fold_and(OptContext *ctx, TCGOp *op) z2 = arg_info(op->args[2])->z_mask; ctx->z_mask = z1 & z2; + /* + * Sign repetitions are perforce all identical, whether they are 1 or 0. + * Bitwise operations preserve the relative quantity of the repetitions. + */ + ctx->s_mask = arg_info(op->args[1])->s_mask + & arg_info(op->args[2])->s_mask; + /* * Known-zeros does not imply known-ones. Therefore unless * arg2 is constant, we can't infer affected bits from it. @@ -988,6 +995,8 @@ static bool fold_andc(OptContext *ctx, TCGOp *op) } ctx->z_mask = z1; + ctx->s_mask = arg_info(op->args[1])->s_mask + & arg_info(op->args[2])->s_mask; return fold_masks(ctx, op); } @@ -1277,6 +1286,9 @@ static bool fold_eqv(OptContext *ctx, TCGOp *op) fold_xi_to_not(ctx, op, 0)) { return true; } + + ctx->s_mask = arg_info(op->args[1])->s_mask + & arg_info(op->args[2])->s_mask; return false; } @@ -1464,6 +1476,8 @@ static bool fold_movcond(OptContext *ctx, TCGOp *op) ctx->z_mask = arg_info(op->args[3])->z_mask | arg_info(op->args[4])->z_mask; + ctx->s_mask = arg_info(op->args[3])->s_mask + & arg_info(op->args[4])->s_mask; if (arg_is_const(op->args[3]) && arg_is_const(op->args[4])) { uint64_t tv = arg_info(op->args[3])->val; @@ -1552,6 +1566,9 @@ static bool fold_nand(OptContext *ctx, TCGOp *op) fold_xi_to_not(ctx, op, -1)) { return true; } + + ctx->s_mask = arg_info(op->args[1])->s_mask + & arg_info(op->args[2])->s_mask; return false; } @@ -1581,6 +1598,9 @@ static bool fold_nor(OptContext *ctx, TCGOp *op) fold_xi_to_not(ctx, op, 0)) { return true; } + + ctx->s_mask = arg_info(op->args[1])->s_mask + & arg_info(op->args[2])->s_mask; return false; } @@ -1590,6 +1610,8 @@ static bool fold_not(OptContext *ctx, TCGOp *op) return true; } + ctx->s_mask = arg_info(op->args[1])->s_mask; + /* Because of fold_to_not, we want to always return true, via finish. */ finish_folding(ctx, op); return true; @@ -1605,6 +1627,8 @@ static bool fold_or(OptContext *ctx, TCGOp *op) ctx->z_mask = arg_info(op->args[1])->z_mask | arg_info(op->args[2])->z_mask; + ctx->s_mask = arg_info(op->args[1])->s_mask + & arg_info(op->args[2])->s_mask; return fold_masks(ctx, op); } @@ -1616,6 +1640,9 @@ static bool fold_orc(OptContext *ctx, TCGOp *op) fold_xi_to_not(ctx, op, 0)) { return true; } + + ctx->s_mask = arg_info(op->args[1])->s_mask + & arg_info(op->args[2])->s_mask; return false; } @@ -1880,6 +1907,8 @@ static bool fold_xor(OptContext *ctx, TCGOp *op) ctx->z_mask = arg_info(op->args[1])->z_mask | arg_info(op->args[2])->z_mask; + ctx->s_mask = arg_info(op->args[1])->s_mask + & arg_info(op->args[2])->s_mask; return fold_masks(ctx, op); }