From nobody Sun Nov 24 23:11:51 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=1720028670; cv=none; d=zohomail.com; s=zohoarc; b=gc90gse7jMz1LHTpnfraaAJlDSm7dfo+9wN6wMWlnvgeQs1VQ7UiVhjcoeril9mTFgawWIkugXCVGmzNWtubueVDyXjEf8mUMK/ZEE4yIK+CVFHReba9QNjCdcFY3SSxlXzEnOkeyxBf/IJs63AxOLhjnZ1B3U0TY5Dhdg5nayE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720028670; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=7spuBkQx1Mu7jCpv4kzIy4W/rs9oZa5KoZssRj5BGLM=; b=KajjOP04V++AtlZAqgCHHmttZMJXsDMIYHKesx0S7Tvse5vePWW8+Xrw/uXoBCet2WUwhTqSqRbCI/DaH17plnXxjFoU9VkHKOKzvEZisWEEzMu5xx81hSbEPE9FJMjP/kVdldPycKBnIU58MBNJGHuAILW8YMN8ozeauj1HKr4= 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 1720028670434528.0298290655188; Wed, 3 Jul 2024 10:44:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP40R-0003NG-H7; Wed, 03 Jul 2024 13:42:59 -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 1sP40A-0003J1-JT for qemu-devel@nongnu.org; Wed, 03 Jul 2024 13:42:42 -0400 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sP405-0005Lr-Rw for qemu-devel@nongnu.org; Wed, 03 Jul 2024 13:42:39 -0400 Received: by mail-pj1-x1030.google.com with SMTP id 98e67ed59e1d1-2c961b5f215so1380011a91.0 for ; Wed, 03 Jul 2024 10:42:36 -0700 (PDT) Received: from stoup.. (174-21-76-141.tukw.qwest.net. [174.21.76.141]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2c91d3e7d7bsm11070030a91.47.2024.07.03.10.42.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 10:42:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720028555; x=1720633355; 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=7spuBkQx1Mu7jCpv4kzIy4W/rs9oZa5KoZssRj5BGLM=; b=uSjzt9lvjqd+BjeB3PxVHjSymKjuwLspoalAFkrwN/zeXpU7JR/2COFbOzEyqImXCu 1exnMwWEAYcZVesVuacIgaeUCCGLSXKDw4PFFqxcQpFJFXPFBJtFoGlqckc8+IftQhqx FqZ/Cl09Gx9dOQjmZNUGD4emmDkN9LGiQL1Tqfpv83AchdVlErxikk6THkE6MAtZ6TR5 QNtrx37QMgohQI7oOjwtLQp/PL1/q7qSdHrebeK52EBpnef1n/S6p33Ie4QD4ainLFEQ cKcXljuvQG0KbnznBLAJfjeXAVpdJ1qM3PLn1VO3n7AK7o/9m2hG/six1OyXUSEtE833 QjdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720028555; x=1720633355; 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=7spuBkQx1Mu7jCpv4kzIy4W/rs9oZa5KoZssRj5BGLM=; b=SRHufD4e7UKWjLcLlReAJes525JCU7vHHSPqwOHZ4u+8zlLM9UKG5MnIDYeiReWqMB wfTOjbVomHPaY+XlrIWTyUGxeoHRaNlsOIpejZ3W4YONKyMTbWcFZcb/Ns6aA0ao7h47 hNK+cvIRb7IQGuaDwLOm34LzTh+xXE8CpyW71/fZiVNCZ0mCy3TkNppB03J48DqAODgl 91yd4siHWZqhxWnsi3HoSqt6DVK7nK0oCV3JCc9so6ga3wZkXvQH2Xv0lxdjKfp1G8Zt xQ21AY7/jeLO8robH5anZ1FpzAq4zXG4/lu8bVrq1YH3ciQab3kghQtM2EK0qYXSnbKW Rjgg== X-Gm-Message-State: AOJu0YwQ7dvVMebQh4doFzd0bDlVWnNELmjE/ZdJ1f7+7K5VamhXRIuu wG3X5VGzlM2+lOrAmYX+WN9YecVb+UjuyPtksyvN1OiYMs+jA/4C+MTv7vtgZemABV6MYGgwzOL 7 X-Google-Smtp-Source: AGHT+IENfYBdzqgRlMiDpUzjBk/rXepj9Ae3rm1N8d8sGkopqcLdCB7bRRNLoBu2C0mUOQorRd98dg== X-Received: by 2002:a17:90a:4214:b0:2c6:dc3b:d6fd with SMTP id 98e67ed59e1d1-2c93d767707mr8395488a91.31.1720028554450; Wed, 03 Jul 2024 10:42:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [PULL 7/7] tcg/optimize: Fix TCG_COND_TST* simplification of setcond2 Date: Wed, 3 Jul 2024 10:42:26 -0700 Message-Id: <20240703174226.2117169-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240703174226.2117169-1-richard.henderson@linaro.org> References: <20240703174226.2117169-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::1030; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1030.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1720028671471100005 Argument ordering for setcond2 is: output, a_low, a_high, b_low, b_high, cond The test is supposed to be against b_low, not a_high. Cc: qemu-stable@nongnu.org Fixes: ceb9ee06b71 ("tcg/optimize: Handle TCG_COND_TST{EQ,NE}") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2413 Signed-off-by: Richard Henderson Tested-by: Alex Benn=C3=A9e Message-Id: <20240701024623.1265028-1-richard.henderson@linaro.org> --- tcg/optimize.c | 2 +- tests/tcg/x86_64/test-2413.c | 30 ++++++++++++++++++++++++++++++ tests/tcg/x86_64/Makefile.target | 2 ++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 tests/tcg/x86_64/test-2413.c diff --git a/tcg/optimize.c b/tcg/optimize.c index 8886f7037a..ba16ec27e2 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -2384,7 +2384,7 @@ static bool fold_setcond2(OptContext *ctx, TCGOp *op) =20 case TCG_COND_TSTEQ: case TCG_COND_TSTNE: - if (arg_is_const_val(op->args[2], 0)) { + if (arg_is_const_val(op->args[3], 0)) { goto do_setcond_high; } if (arg_is_const_val(op->args[4], 0)) { diff --git a/tests/tcg/x86_64/test-2413.c b/tests/tcg/x86_64/test-2413.c new file mode 100644 index 0000000000..456e5332fc --- /dev/null +++ b/tests/tcg/x86_64/test-2413.c @@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* Copyright 2024 Linaro, Ltd. */ +/* See https://gitlab.com/qemu-project/qemu/-/issues/2413 */ + +#include + +void test(unsigned long *a, unsigned long *d, unsigned long c) +{ + asm("xorl %%eax, %%eax\n\t" + "xorl %%edx, %%edx\n\t" + "testb $0x20, %%cl\n\t" + "sete %%al\n\t" + "setne %%dl\n\t" + "shll %%cl, %%eax\n\t" + "shll %%cl, %%edx\n\t" + : "=3Da"(*a), "=3Dd"(*d) + : "c"(c)); +} + +int main(void) +{ + unsigned long a, c, d; + + for (c =3D 0; c < 64; c++) { + test(&a, &d, c); + assert(a =3D=3D (c & 0x20 ? 0 : 1u << (c & 0x1f))); + assert(d =3D=3D (c & 0x20 ? 1u << (c & 0x1f) : 0)); + } + return 0; +} diff --git a/tests/tcg/x86_64/Makefile.target b/tests/tcg/x86_64/Makefile.t= arget index 5fedf22117..eda9bd7396 100644 --- a/tests/tcg/x86_64/Makefile.target +++ b/tests/tcg/x86_64/Makefile.target @@ -8,6 +8,8 @@ =20 include $(SRC_PATH)/tests/tcg/i386/Makefile.target =20 +X86_64_TESTS +=3D test-2413 + ifeq ($(filter %-linux-user, $(TARGET)),$(TARGET)) X86_64_TESTS +=3D vsyscall X86_64_TESTS +=3D noexec --=20 2.34.1