From patchwork Wed Apr 10 07:22:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 787485 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp571027wrs; Wed, 10 Apr 2024 00:41:11 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX10mnZhZJR2ViRkwj+AgfB2zmSrxqFPxpGZv+5kClk1UwcdseffTiEmJi1xwR95GKcH5Bxj8ZaxSg+iaLv5VJM X-Google-Smtp-Source: AGHT+IG602eE8aTg4GNDGnQJVArEFuLAt0PmfpfFL0p4D2mgA7V8T+ZEqyuchK55f4IATwFUf23B X-Received: by 2002:a05:6214:2021:b0:69b:9a1:b9bb with SMTP id 1-20020a056214202100b0069b09a1b9bbmr1923336qvf.50.1712734871299; Wed, 10 Apr 2024 00:41:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712734871; cv=none; d=google.com; s=arc-20160816; b=ErVU6i58G2mDKyYVYRmWrPQS2SNAp85zOH/oyI1wVOMA3j4xbINiNZqsLuGi3cl4e6 uPHuz+nYidnIEb9HhZLOagN5E74rd7SuA2+/DDUf1giCQ5e2sVinIdNciYYLqaVGQYzv ICM1xVsGAKa3RZcQcYeA1Y795U2tTMSrBRlBeZ6OvBhSVwEPYxEtLlxxAOinbwCnq796 mCMXJOnWVxqAubKiH9kNqbBYS4l8e1v2WdIBjGFw/EMZZ7ne+wl0guddP+Wbe1mgsa2D 62Ivkwyc8dy7qekJ47JmZwXKZH/aQwUDj7WJDw70RfVUNrkEIzGq1TNMoQHKEGexENc1 zXCQ== 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:cc:to :from; bh=lBZmtGivFzUHHUtZXC+OvlMRvOqRRCU7oM0zgyU1x6k=; fh=K4abbxCgZAPvqzOXA+PZ7RIZh+KufMVJze7rXLOwES0=; b=qiGmm4gpAUHfKPCgcubNzbDRQ++HxZJUtVXfzFRn9lKXF2ndABk77WhMl7RAY1Rnow BBLUml8wCfU6Eg1koDFFyXgE9iUXqRtA1qIR/BCUIAOt+KvW8iFYgK9TYbfx0iONcFDB xPvYz346ysdecNI1HQSga/jHuNCfKsKep2nVarJF/bncIcw9Y4CSVp/XJ1VFLFLq6J0e adPNu7Z9R5WCsNZt5hLULgtGvofePeDn/LTJ2dCssWFeonJbEB/QpLz44fMZVSv31hdX pTpk1L7NLtjc/KQgOLkPkRnqjFyeDTImgkrcjNyhiZd8lRpC1UOlzKcNPFLFC3IO5Acy Sztw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id e9-20020a0cf349000000b0069b2068681csi5006657qvm.495.2024.04.10.00.41.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Apr 2024 00:41:11 -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; 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" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ruSPq-00037b-4Q; Wed, 10 Apr 2024 03:30:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ruSPZ-0002wR-30; Wed, 10 Apr 2024 03:30:26 -0400 Received: from isrv.corpit.ru ([86.62.121.231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ruSPW-00055p-FR; Wed, 10 Apr 2024 03:30:23 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id DF6835D6BA; Wed, 10 Apr 2024 10:25:07 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id 84E07B02FA; Wed, 10 Apr 2024 10:23:09 +0300 (MSK) Received: (nullmailer pid 4191873 invoked by uid 1000); Wed, 10 Apr 2024 07:23:04 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Richard Henderson , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Michael Tokarev Subject: [Stable-8.2.3 74/87] tcg/optimize: Fix sign_mask for logical right-shift Date: Wed, 10 Apr 2024 10:22:47 +0300 Message-Id: <20240410072303.4191455-74-mjt@tls.msk.ru> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=86.62.121.231; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, 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.29 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-bounces+patch=linaro.org@nongnu.org From: Richard Henderson The 'sign' computation is attempting to locate the sign bit that has been repeated, so that we can test if that bit is known zero. That computation can be zero if there are no known sign repetitions. Cc: qemu-stable@nongnu.org Fixes: 93a967fbb57 ("tcg/optimize: Propagate sign info for shifting") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2248 Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé (cherry picked from commit 2911e9b95f3bb03783ae5ca3e2494dc3b44a9161) Signed-off-by: Michael Tokarev diff --git a/tcg/optimize.c b/tcg/optimize.c index f2d01654c5..6fcdda68ef 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -2123,7 +2123,7 @@ static bool fold_shift(OptContext *ctx, TCGOp *op) * will not reduced the number of input sign repetitions. */ sign = (s_mask & -s_mask) >> 1; - if (!(z_mask & sign)) { + if (sign && !(z_mask & sign)) { ctx->s_mask = s_mask; } break; diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target index ea3e232e65..0efd565f05 100644 --- a/tests/tcg/aarch64/Makefile.target +++ b/tests/tcg/aarch64/Makefile.target @@ -10,6 +10,7 @@ VPATH += $(AARCH64_SRC) # Base architecture tests AARCH64_TESTS=fcvt pcalign-a64 lse2-fault +AARCH64_TESTS += test-2248 fcvt: LDFLAGS+=-lm diff --git a/tests/tcg/aarch64/test-2248.c b/tests/tcg/aarch64/test-2248.c new file mode 100644 index 0000000000..aac2e17836 --- /dev/null +++ b/tests/tcg/aarch64/test-2248.c @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* See https://gitlab.com/qemu-project/qemu/-/issues/2248 */ + +#include + +__attribute__((noinline)) +long test(long x, long y, long sh) +{ + long r; + asm("cmp %1, %2\n\t" + "cset x12, lt\n\t" + "and w11, w12, #0xff\n\t" + "cmp w11, #0\n\t" + "csetm x14, ne\n\t" + "lsr x13, x14, %3\n\t" + "sxtb %0, w13" + : "=r"(r) + : "r"(x), "r"(y), "r"(sh) + : "x11", "x12", "x13", "x14"); + return r; +} + +int main() +{ + long r = test(0, 1, 2); + assert(r == -1); + return 0; +}