From nobody Thu May 16 21:33:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1711491846; cv=none; d=zohomail.com; s=zohoarc; b=HqgpZbTW+MCIaJMmCnocrPvir+2xuxmt5hhGjLmvqcdvZtlN8WRkYXfI7fE0kC/6em0M+1wVGdmMYDJ2W4mbZN0dJ9yi4/JtEfhwqZn4UuZTJioxF5mmg7QGHX7F7w+2pKW+6pcZzG+7Xd1zZxBS7gy3nfeFFuY2tbpV1W0BG5k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1711491846; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=6YBJjSBn4egJqzEYD4EAYt1+uubsMfVYYuDQBsk59/w=; b=N6Lxsfke0VfLQ3gmCjDf/9D93/vmQtqVPwt3ZdXprn0SUDc/1GKQ/lW8E2gPLwi6LpGkLCIk/5wZ1/W0TP6RkPc/T8kB7ekCcrew4ODrucsyWUYmxRp4d3j0mXCzyQksXY12ycjXeopb6iYNjRX38U7yvf4bsaKLut2EssiqgMg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1711491846576266.5427256894104; Tue, 26 Mar 2024 15:24:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rpFCG-0002n9-4h; Tue, 26 Mar 2024 18:23:08 -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 1rpFCE-0002m3-Kw for qemu-devel@nongnu.org; Tue, 26 Mar 2024 18:23:06 -0400 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rpFCC-00044b-Up for qemu-devel@nongnu.org; Tue, 26 Mar 2024 18:23:06 -0400 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-6e6ce174d45so4516442b3a.3 for ; Tue, 26 Mar 2024 15:23:04 -0700 (PDT) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id le12-20020a170902fb0c00b001e0f366139esm1962577plb.119.2024.03.26.15.23.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 15:23:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711491783; x=1712096583; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=6YBJjSBn4egJqzEYD4EAYt1+uubsMfVYYuDQBsk59/w=; b=Tf/Xwx1+IwuENGGnNO7p1oCqA4VR8epC7o5GW2a/ho4qZJIC9aczVYlcO58xQi/S6M U4Kty3OCuwDhLJA/r5b8Mun798XI282K487aWRRlNB0VA1uWzfmOxxf1LlntLKT0huQL Hzj7YevKxTAeGHjiqM5mnQ5MSBBPwpgTt1W5BC92qEDxcmAMGyU3ORVePzHZbDFkXs3L Tq9OKFc9fuGxtbk3T4M5Qewd5CH1hxMs7eXNssnSE+RKsJrp1spKzdUBpXxFcPto1SnL onTrks4EResqFUi1AfV0uAd7PExmYtNXQPz5/gzRopBDzJlRk2GoAaLtQaax/uYuACxo sx3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711491783; x=1712096583; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=6YBJjSBn4egJqzEYD4EAYt1+uubsMfVYYuDQBsk59/w=; b=HAdo0C2obRqgZUa48O3prJNA6d3UkTduY+ANRUovH1MYRRFiywiCHhH8hi4TCQLFTP SSSzQaHPkwLkRAgz4s8veFcQltb8N0tJRvklQYSfCwonQvEEQk6sn+0wKBf1jNq6CVOW iX5fzWO2P6RsyZKS4erpsoNIUl12DesdexHw/uEtUMmRirMv4+zvWToAr8RDAO/IbKbW 9UdWOVvHcZYNpznI/WnXbLoXWOROmrSGB2XvBtwxkbCefVaZ1hJnCS2Q5wSF74EqaUz1 LSJJFEHCGNrgoSYkPWpxnOCJFxKP+lb1zLxHlDhA1HElrvGG+vxS8qBbYRc1dJWy4sLn pV3g== X-Gm-Message-State: AOJu0YxoBNbCPNFaXgQE7mGnCMhNP/84pIT/NYqDzv4/53G1HqNY5jJM h/btNT6Iq+RnlDtcJ+/FfZDdOlW/HPJBKDC7+xufu68cuoNSRk4uRayP7aLpAOp6I2oTzmpBy1U x X-Google-Smtp-Source: AGHT+IHXIVjbbBWwusKoh2ZVNMWLu08SpMNdNSObLn4+M9YIjHrw5PVO5XKJjFArIT5IxEpNdcRGMA== X-Received: by 2002:a05:6a20:158e:b0:1a3:abcf:dba with SMTP id h14-20020a056a20158e00b001a3abcf0dbamr12096115pzj.37.1711491783244; Tue, 26 Mar 2024 15:23:03 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org Subject: [PATCH for-9.0] tcg/optimize: Fix sign_mask for logical right-shift Date: Tue, 26 Mar 2024 12:22:59 -1000 Message-Id: <20240326222259.528099-1-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::42d; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42d.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1711491847824100001 Content-Type: text/plain; charset="utf-8" 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=C3=A9 --- tcg/optimize.c | 2 +- tests/tcg/aarch64/test-2248.c | 25 +++++++++++++++++++++++++ tests/tcg/aarch64/Makefile.target | 1 + 3 files changed, 27 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 =3D (s_mask & -s_mask) >> 1; - if (!(z_mask & sign)) { + if (sign && !(z_mask & sign)) { ctx->s_mask =3D 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..6cc20e3c6c --- /dev/null +++ b/tests/tcg/aarch64/test-2248.c @@ -0,0 +1,25 @@ +#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" + : "=3Dr"(r) + : "r"(x), "r"(y), "r"(sh) + : "x11", "x12", "x13", "x14"); + return r; +} + +int main() +{ + long r =3D test(0, 1, 2); + assert(r =3D=3D -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 +=3D $(AARCH64_SRC) =20 # Base architecture tests AARCH64_TESTS=3Dfcvt pcalign-a64 lse2-fault +AARCH64_TESTS +=3D test-2248 =20 fcvt: LDFLAGS+=3D-lm =20 --=20 2.34.1