From patchwork Wed Apr 10 05:43:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 787470 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp542592wrs; Tue, 9 Apr 2024 22:49:52 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWvJt+vjoGMZoeKTxe1yVZuXac4ueUA/dGHJu9Si68ICy4MuwH2oXUcoUQ9RMOg30t7sOYa0XX6hfkP16IwboIJ X-Google-Smtp-Source: AGHT+IHoD5SAls8QoaO6G4hwUQcL9pW3D1IoTlY8/Iej1T6iT4b4YY6shFGgueEdV52QdpblS4rL X-Received: by 2002:a05:620a:580e:b0:78b:d447:4752 with SMTP id wm14-20020a05620a580e00b0078bd4474752mr1581948qkn.17.1712728192183; Tue, 09 Apr 2024 22:49:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712728192; cv=none; d=google.com; s=arc-20160816; b=Tv9hzGnifTfieAYVuaQ8mkfsJtmWniihlNAYnRwpZVGYdXVilgwWJFtXgty0GUt1Ea 2Wh/orJq7u2xfkppKCL+ko1euH4I7XrCzwP4f+y0FNz4RThyZDwK+tEmnZQIWVzA3VbY 1m2ywpRehSSR2Rn9UWvkxU1CPmKEYAmDtsMdrYfeStjlMZhk891CXB6818qs7hzkGHIj xeBn2rfUgZSR12VYPoQnGiatHom9PMfsQo4y4MBEO2379SCC2lenN5K9vOzjRwSeCEur m1i8KpIB5sTZxmRY2vG6vUazy3DvxJ82bmCSNLhNydTwjOgwMdakYXgyynh/szVzowFV Q3CQ== 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=4N0y2iYQrQUv/tSmVuta8Jx5lTcfTNEZkTbXlAzrVMI=; fh=K4abbxCgZAPvqzOXA+PZ7RIZh+KufMVJze7rXLOwES0=; b=iScQAnQ4ola73Vs2pIVqzGvkAGbBIYWvI6pvE8cyvH22AF9PobwqSg2rN2AWXK4zlk 9p98ROtPBr3030MeV19wtnfICrPgcGG1JZj7DYxa1VW18KaeFQu4at4tjHjxTxht2115 piYLO7RHqtgLG2d17vxHnSh0WDA/6VzQXRTYWUdMc41psvGdk1zTOBVYBUey7VprVk28 nk8fBQVD9cEagvN96hveStS8cwVLslHOtMVxb23Fm9IS6ZzpABk2U3OwFsfFNGEBu8qa y1ZmK7Am7w+ZzA57m6YBiiIGtHIl1m+99m1YcgWJYhoag7hRHjxXoiXtrV9UbtzHowIw mR1A==; 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 bp19-20020a05620a459300b0078d777d7ba9si1337756qkb.203.2024.04.09.22.49.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Apr 2024 22:49:52 -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 1ruQoG-0004CO-DU; Wed, 10 Apr 2024 01:47:48 -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 1ruQoD-0003t6-OQ; Wed, 10 Apr 2024 01:47:45 -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 1ruQoB-00023D-OL; Wed, 10 Apr 2024 01:47:45 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 13E015D4FC; Wed, 10 Apr 2024 08:46:17 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id CD2CDB0163; Wed, 10 Apr 2024 08:44:18 +0300 (MSK) Received: (nullmailer pid 4182111 invoked by uid 1000); Wed, 10 Apr 2024 05:44:16 -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-7.2.11 36/41] tcg/optimize: Fix sign_mask for logical right-shift Date: Wed, 10 Apr 2024 08:43:57 +0300 Message-Id: <20240410054416.4181891-36-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 (Mjt: trivial context fixup in tests/tcg/aarch64/Makefile.target) diff --git a/tcg/optimize.c b/tcg/optimize.c index ae081ab29c..b6f6436c74 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -1907,7 +1907,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 5e4ea7c998..474f61bc30 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 +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; +}