From patchwork Wed Jul 3 17:42:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 809355 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp808114wru; Wed, 3 Jul 2024 10:44:30 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVjnyAvJohQpOV0IIPflZ/Xt0o9Uiay23ygyQrOeVYOkP/M0a8d1h75ZYNwxLLxG5edK/qHVwXWVdkbhsLTg+dk X-Google-Smtp-Source: AGHT+IH4BxU+E6KlPo2tlpuMDSgGLCiTOsdD7VaZWwcusXRft88oN61piLLFhVgB70u3sTUp6MwF X-Received: by 2002:a05:6122:3d41:b0:4ef:5744:46a with SMTP id 71dfb90a1353d-4f2a563d152mr16539017e0c.1.1720028670231; Wed, 03 Jul 2024 10:44:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720028670; cv=none; d=google.com; s=arc-20160816; b=Bp97zarD9ucx4d5DS2VduAyywuQcVfHhKDoEm8hyI4XHoogQ6OIujH+FX9tZ0e+2ku jv1mQCiJZp21Y6WFvCkd5xKgilbN6k6Z95A4rK87IoGHmKikcyJYCA73eBepDf18FZau /lQHwo7NU5x6St9U+RcW84+Ulk2ZooA6uM92gfePkkCL7vAKuPTA+voOddusA5tZ+z9i kEZDc6ELQePJ13JBFJYKer0r+InSpeFA0BGd20yvpU4CmJbvFrLEZQVGiMyuo8bvOhki 8I7m7WGyXwD7AncA5eyNr0RzLXGeJiqE0XpRA/B8gHI0GyF6eT9iGerWFWWdaRU4OksO e0oQ== 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=7spuBkQx1Mu7jCpv4kzIy4W/rs9oZa5KoZssRj5BGLM=; fh=mnw+9DwEUea7x4FcuVZcSRMYzohcZl+IvzTDrM28dxc=; b=xiV9GKuJ0jmPxuOOO3p4pVa8oxhlX2XmKJgb3LopLj42rsq1s1lBrk+aVlvgNmqB/D XBPo/9k5fhSXJAsGDoB1oB07vNLUzRI6xur0Ouclb65U959JWIIeOiHj/j3uK5RHfNSz cFbGA7u83cKJ45zUY+r00G6blvweEmAc1BA2z9XYC33EqOgdz0smSMawKtpVuT3lQSrg yRkBv345lvt1JyNYT1pA5YOIqOILvUMo1yWf8/jBoDDyQvWnpnsevDNTij+zIucpn4X0 Nt/+pW3EAvb3+llTMulYRQ2Uu/xmBKPnDavKa92h0TrNlvvbqYtZcmrMhLLi+grWy7dv 8obg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uSjzt9lv; 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 af79cd13be357-79d6934d17esi1366031085a.716.2024.07.03.10.44.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 03 Jul 2024 10:44: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; dkim=pass header.i=@linaro.org header.s=google header.b=uSjzt9lv; 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 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) 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-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) 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) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, =?utf-8?q?Alex_Benn=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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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ée 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) 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" + : "=a"(*a), "=d"(*d) + : "c"(c)); +} + +int main(void) +{ + unsigned long a, c, d; + + for (c = 0; c < 64; c++) { + test(&a, &d, c); + assert(a == (c & 0x20 ? 0 : 1u << (c & 0x1f))); + assert(d == (c & 0x20 ? 1u << (c & 0x1f) : 0)); + } + return 0; +} diff --git a/tests/tcg/x86_64/Makefile.target b/tests/tcg/x86_64/Makefile.target index 5fedf22117..eda9bd7396 100644 --- a/tests/tcg/x86_64/Makefile.target +++ b/tests/tcg/x86_64/Makefile.target @@ -8,6 +8,8 @@ include $(SRC_PATH)/tests/tcg/i386/Makefile.target +X86_64_TESTS += test-2413 + ifeq ($(filter %-linux-user, $(TARGET)),$(TARGET)) X86_64_TESTS += vsyscall X86_64_TESTS += noexec