From patchwork Fri Mar 29 22:20:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 784080 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e01:0:b0:33e:7753:30bd with SMTP id p1csp3426469wrt; Fri, 29 Mar 2024 15:21:51 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWxT1eXd8CsH8FhQbPETVtfzDnGqKrTxB8KJ/tJfL3Uipr23RnQ9oLs7QopGZRz4gFrvxOIN2RVwb7LrXVmdmjm X-Google-Smtp-Source: AGHT+IGZPqjXKYP4ETIhKmgBI/mJc6FGDd/vsqIAEQm20qK1ihJHAjh8uczx2pXI75CLNm8d37hw X-Received: by 2002:a05:622a:1187:b0:432:cf93:d369 with SMTP id m7-20020a05622a118700b00432cf93d369mr155880qtk.2.1711750911269; Fri, 29 Mar 2024 15:21:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1711750911; cv=none; d=google.com; s=arc-20160816; b=FAIgXRV1qVBxzZUbHyBMjl4LWvmG5URDaI4MP4aISPBJ5Ma4L4ZgcyyN8fq6HbCmQQ kTYzex+6Llf7b/B/K5Qfh5NMDia33W7AMq7zfeCyk2zhSDRRnMSbbGJFOpfb6rWy8eLB eGKE9fTuNud3BNXGqDvsoFJcOFUY2VK8Rkm3H5wPGTD8KyCFEJrAv9EtCWoCfmMhhU/P lShDtFzIDTVxNwUVlcBtUorxwsOjXZFQZRUWp966sb8/qt2esrmnYiuQ5/HkjH1soFtO R2apAiEgiVSpB1XYuYmmUBQBzBsEv+VulgNtsD5Q0BWWGv02k1JQ4k44b7eU4Fyix5fT /L3A== 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:dkim-signature; bh=3dondGlVn7Nspk+b15ZO4C68ipaZNt0/1iWHRvOdtfQ=; fh=aYwv1qvAWDHKcZLZyhvLuIoAkBRd6ysYy/Itgr1WhFg=; b=ELk2oPYfLKsvVf78I2Sz2A97dOJ9RvQ0yem6+HjeuG0ynhPHHTsFMuUrdQOLtVyJkO woxDB9ik4S33P/fyvAlDEIN3H9x/N8ECn4oaJX2MDSeBrHa9iqedRRQeipoavicBg7ef YQAU426Yr/iZtb9TcVnsexAYvMblanBriNJsPrEBhtchNrKvrIqzX/QT/MLnoOyfsWB5 dQyl7qR9XO+2IaNN356zagXELlBQRM1AKR3n+60lTes3/5lXcamEYcwfuiX8LZ1jPvyl eW6d9IJ2t1bbnz6zlgz230+ghF0WIy1WvYStnxIenBG4JFLX7KgkNIm3MGPHktmLVosA icQw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OI4rJQbd; 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 et14-20020a05622a4b0e00b00432c1c86992si1998885qtb.286.2024.03.29.15.21.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 29 Mar 2024 15:21:51 -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=OI4rJQbd; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rqKai-00057e-Hj; Fri, 29 Mar 2024 18:20:52 -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 1rqKah-000578-6B for qemu-devel@nongnu.org; Fri, 29 Mar 2024 18:20:51 -0400 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rqKaf-0001pg-BU for qemu-devel@nongnu.org; Fri, 29 Mar 2024 18:20:50 -0400 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-6e6b3dc3564so1993113b3a.2 for ; Fri, 29 Mar 2024 15:20:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711750848; x=1712355648; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3dondGlVn7Nspk+b15ZO4C68ipaZNt0/1iWHRvOdtfQ=; b=OI4rJQbdxIVAbSx4eeo2MEJTvpoQR3eUpSVzIO3au2bpnntTqCb9ra1X0iyT3ossu1 IFSQF+jXkUTUV0JdlwDLVaY6Dod/hnYZZBFJOehUccd+rbE1wDc2uc3tkcXDWBWS8Vo9 Y76TVb/cvWsX3tCpVt2GSgG7DPdp2Y+V1ofT+9r824CU/85oAu292AW5u01O5HIrCOKQ zxH7Jn5e1g+OsOR2JX7OMLv8MPeeHOksHt2EENdD3u0XhtLgyRAt7BMwcvccP7xtvLTc eyNq4p+kDUxmWTm9YITQugMmslJRWOJXd677kH7HN6QMbig8pqn0w1v5UJ56Qf6GTosY YN9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711750848; x=1712355648; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3dondGlVn7Nspk+b15ZO4C68ipaZNt0/1iWHRvOdtfQ=; b=csePmz6DPygQPAUHSB2NM5EFc44f6sEN8rRARGZ1iNciry6lAIHKBjdE8OKOsQ8CkM nU9YfZvScmXFnemQBpb4oCKAP+DFWZm2yrp4KaoVw77x41NgGZQvpP9951UqxybywAqw 5Gcc5aV6nNLym1uSGA9ymY5JUUCuawWF/ixSw+fu6wlo145mX0ZrUwG+VoebscQimk6T H+JtxSZ2T50iwexAb3EdWR4Qm7KqoA3Pxn/iPsjuu5pwFZ+p9FITvyUmkW/eDJ7r73GC LNBg/HFJl9l9DorGdTLX7dHngGgqLNTUV+TkaO+KgLSTaCJyvWu3jRGQV4T/pmzMzeyU wzXg== X-Gm-Message-State: AOJu0YyXWW8QDkW81xIwS3++rnf1M5V7NDYwQdlJfu8uxyg0B+KPSAuj pFcn09/z4v3cp11hUx8M/Jcmvc88SXCwR4UszIy4dhSM2EB5qB2gaYdrysfl4KqBVMeVWUcTJNw Y X-Received: by 2002:a05:6a00:4fc6:b0:6ea:ab48:5dd9 with SMTP id le6-20020a056a004fc600b006eaab485dd9mr3564600pfb.6.1711750847953; Fri, 29 Mar 2024 15:20:47 -0700 (PDT) Received: from stoup.. (098-147-007-212.res.spectrum.com. [98.147.7.212]) by smtp.gmail.com with ESMTPSA id lc24-20020a056a004f5800b006eaacc63435sm3579811pfb.173.2024.03.29.15.20.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 15:20:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 5/7] tcg/optimize: Fix sign_mask for logical right-shift Date: Fri, 29 Mar 2024 12:20:35 -1000 Message-Id: <20240329222037.1735350-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240329222037.1735350-1-richard.henderson@linaro.org> References: <20240329222037.1735350-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::431; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x431.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=unavailable 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 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é --- tcg/optimize.c | 2 +- tests/tcg/aarch64/test-2248.c | 28 ++++++++++++++++++++++++++++ tests/tcg/aarch64/Makefile.target | 1 + 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 tests/tcg/aarch64/test-2248.c diff --git a/tcg/optimize.c b/tcg/optimize.c index 752cc5c56b..275db77b42 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -2376,7 +2376,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/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; +} 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