From patchwork Thu Apr 18 20:02:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 789853 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp747126wrm; Thu, 18 Apr 2024 13:03:30 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXTzQK3vOftXKmzhOZJYCBwRYaEIxzsDB+YHgEOVa64c3JZkNgHkjdVvbslHt1ydF1aFWm/oEHNM88dSVKAd8Hh X-Google-Smtp-Source: AGHT+IFaGePo4qgMahbwJzTwamGDL6XBJz445y4e8jiJPF1p14Q9fjqHcxFYl2jEM6KYlw+RP8Ar X-Received: by 2002:a9d:67d1:0:b0:6eb:71f0:829 with SMTP id c17-20020a9d67d1000000b006eb71f00829mr23025otn.37.1713470610377; Thu, 18 Apr 2024 13:03:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713470610; cv=none; d=google.com; s=arc-20160816; b=Dy9QWWOLq/PufOS8wTyOab8MUWIUJiC+BVEp3Nhk7B0lkoEZAPo3A0Pp9sFJNBVZIR s774EjClk8oycS+8VP3Oq+Nu6zrYu8F02bZXOqU6aL1PhdYA/hHofZqnQEW5Peb7hc58 knSaBiXwqsx9/0iVY4CryO7gPfVdVaYiVrIOJDaQs3CL0VrRAg5UBsJ370M/RTHYK+Cg 3JUSNGn/u0vLQhooPxJYUtrKmbWDD9T6tQ98lJSBj01QK9UFZyUPnE4mhtIw/wPqPN22 nxEyNBvY0+H5Vb0SlOJVzhTIZRbC1Dy1xCOrh2yTZ/X0qNX3MnJBjVWV+YHG1NBsrvAx VTcQ== 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=PYkZpHdcT0po+dxox5DgZw1L7RI86YqBgFpoJqNP6+Q=; fh=bMaafE1clBtiBaCrlbrbcY1DSEPhhFUklUk4XoVHiPU=; b=fSQwLUtVppZJKpV/oxagRpZ3GwL8BVh0IUbD+R73sAD2GAOyLMe7mLTIvWBbSQ+Pz0 j8H5C7apElQwr7uTc+SBpTr+Z1Rt7r5rzpX5erQ2QJXnkMeeMNwAXqlkgI62QPSanMUh JTOxfXJ/9ZeSCD/gNYNEfZwPZeuihH/QRNenQiP46khd+oOGzBzbwce27a5MIZWC+0Ah 6P05qDr6ChRkh8TMJruMRbedjiTbnYtYl3U2fUdxD1lDFmvXQdpL1cizEXWKqFcUli2t BZ1yzf/9iTpJ7/hUOS7QMTxVghEFZsvuRp6M5r90T7Hl3G2HhTGN2UYqVpHxOkDJpIyg Y7SQ==; 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 f9-20020a0561020c8900b00479d969b25asi552791vst.361.2024.04.18.13.03.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Apr 2024 13:03:30 -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 1rxXxu-0001VL-Vd; Thu, 18 Apr 2024 16:02:39 -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 1rxXxn-0001UN-GW; Thu, 18 Apr 2024 16:02:33 -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 1rxXxl-0005Fp-FZ; Thu, 18 Apr 2024 16:02:31 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 346515FE09; Thu, 18 Apr 2024 23:02:27 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id 9647BB93EF; Thu, 18 Apr 2024 23:02:24 +0300 (MSK) Received: (nullmailer pid 952842 invoked by uid 1000); Thu, 18 Apr 2024 20:02:24 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Richard Henderson , Michael Tokarev Subject: [Stable-7.2.11 42/59] tcg/optimize: Do not attempt to constant fold neg_vec Date: Thu, 18 Apr 2024 23:02:02 +0300 Message-Id: <20240418200224.952785-1-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 Split out the tail of fold_neg to fold_neg_no_const so that we can avoid attempting to constant fold vector negate. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2150 Signed-off-by: Richard Henderson (cherry picked from commit e25fe886b89a396bae5847520b70c148587d490a) Signed-off-by: Michael Tokarev (Mjt: context fixup in tests/tcg/aarch64/Makefile.target) diff --git a/tcg/optimize.c b/tcg/optimize.c index b6f6436c74..100b75efd8 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -1634,16 +1634,10 @@ static bool fold_nand(OptContext *ctx, TCGOp *op) return false; } -static bool fold_neg(OptContext *ctx, TCGOp *op) +static bool fold_neg_no_const(OptContext *ctx, TCGOp *op) { - uint64_t z_mask; - - if (fold_const1(ctx, op)) { - return true; - } - /* Set to 1 all bits to the left of the rightmost. */ - z_mask = arg_info(op->args[1])->z_mask; + uint64_t z_mask = arg_info(op->args[1])->z_mask; ctx->z_mask = -(z_mask & -z_mask); /* @@ -1654,6 +1648,11 @@ static bool fold_neg(OptContext *ctx, TCGOp *op) return true; } +static bool fold_neg(OptContext *ctx, TCGOp *op) +{ + return fold_const1(ctx, op) || fold_neg_no_const(ctx, op); +} + static bool fold_nor(OptContext *ctx, TCGOp *op) { if (fold_const2_commutative(ctx, op) || @@ -1949,7 +1948,7 @@ static bool fold_sub_to_neg(OptContext *ctx, TCGOp *op) if (have_neg) { op->opc = neg_op; op->args[1] = op->args[2]; - return fold_neg(ctx, op); + return fold_neg_no_const(ctx, op); } return false; } diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target index 474f61bc30..bd29446835 100644 --- a/tests/tcg/aarch64/Makefile.target +++ b/tests/tcg/aarch64/Makefile.target @@ -10,7 +10,7 @@ VPATH += $(AARCH64_SRC) # Base architecture tests AARCH64_TESTS=fcvt pcalign-a64 -AARCH64_TESTS += test-2248 +AARCH64_TESTS += test-2248 test-2150 fcvt: LDFLAGS+=-lm diff --git a/tests/tcg/aarch64/test-2150.c b/tests/tcg/aarch64/test-2150.c new file mode 100644 index 0000000000..fb86c11958 --- /dev/null +++ b/tests/tcg/aarch64/test-2150.c @@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* See https://gitlab.com/qemu-project/qemu/-/issues/2150 */ + +int main() +{ + asm volatile( + "movi v6.4s, #1\n" + "movi v7.4s, #0\n" + "sub v6.2d, v7.2d, v6.2d\n" + : : : "v6", "v7"); + return 0; +}