From patchwork Mon Jul 1 02:46:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 808820 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp1375607wrr; Sun, 30 Jun 2024 19:47:30 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU6gCw5x10ZiobGVUxwKhf8ANkd7aA1/nyO3pA7oZoUw4BNLb1Q7ezb2PhiLIY0oang7aWt7UpA0q+gy+hfqdCZ X-Google-Smtp-Source: AGHT+IHESyJLjW+vGd6QGgfii+q2wQMpDwo8PZiQbMUf/EWizZOTiRzz01+yLIOX3VSyLT/M1qEx X-Received: by 2002:a05:6214:e64:b0:6b0:91d4:5825 with SMTP id 6a1803df08f44-6b5b719b777mr52178286d6.56.1719802050353; Sun, 30 Jun 2024 19:47:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719802050; cv=none; d=google.com; s=arc-20160816; b=TYCbaj1+4+jpi4mgjtWMI85/N3LJmtwB69P5IJmUttP3MdxV2VXbXxgqPW6tLqj0pO cjq9dgAM76+ipl1b3NC7zEii46BDG0kRyT+xHjQXGTS4qh75FEHzmcVxoQY6XN5qQHrr ygyJfAO9qq8jVS2UP6ZL/9OPWRwHjBaiot85JntvhlTGKIynosBDHuGfy9D2c/lVgjSH qK/wJ3x7g4VW7EPL6kbQYcfQ4Thj3fwJp7ZuOwno0wfwmp02Ru+h91LDa03UWrMaQlZV Idaf5RQ4M1j/Hun+mE8xHUGgejCujpWZga7yqhPLF4A7YvmYYP2TkWIiK8oFyrf36w6e Ln2A== 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:message-id:date:subject:cc:to:from:dkim-signature; bh=7uk0+/ouRfw5Hh1qNoz0AFZnn50xl2En+npPSW4GWrk=; fh=fFT0iruVrcjw40FlH1xdCFf2IanVIZbN8gO7zVuh+U0=; b=T6m9u7t5Z3XidJH0jwODxgwWNfd9GinOhdZ4/JlEtTcuM9Jhe9YII6BTQxwtI8qhAH duonrOmg/p6wcqTpzirHNKmMGbrOzdDzpm8RS82pzY5wCkfIUrxYtREU2dSuWym0R5PM So5UMAxl34I9K34e4PRNLiNw6sSYMH+uMF4j4WAhd1H4CfrGNUyHzo7MQdlABiICt7JK Jt4CEfHYfm+zmu24MFMeYlHtUxBklZ5v96GYK1RiyaKfxt254ykdnVbJL3R+2En9mllI R1XQuCUx8QVmNOVpo16GnFjo7Uz7YqmoUgFWE9pcsKKC3nhHETe/FdPEGRevJjQW8NoQ W1Rg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aZILsPdX; 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 6a1803df08f44-6b59e36331asi73078306d6.112.2024.06.30.19.47.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 30 Jun 2024 19:47: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=aZILsPdX; 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 1sO73n-0001iJ-It; Sun, 30 Jun 2024 22:46:31 -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 1sO73l-0001ht-8f for qemu-devel@nongnu.org; Sun, 30 Jun 2024 22:46:29 -0400 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sO73i-0005Ut-Uv for qemu-devel@nongnu.org; Sun, 30 Jun 2024 22:46:28 -0400 Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-7066c799382so2049936b3a.3 for ; Sun, 30 Jun 2024 19:46:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719801985; x=1720406785; 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=7uk0+/ouRfw5Hh1qNoz0AFZnn50xl2En+npPSW4GWrk=; b=aZILsPdXpQjZ7lm84Vjr2dCrri6/q4v7fuz8h8PDkUCA+5Z+usRMicG020x+sRFA5X oAaTH0NIHYssOPNRZKMPawfTWnuKvYX/Lv5QfV1X++7MgkbrduZGD+GXI5BGILvOs4Xr VXBWOLmEPq5Bz9DhVWGvpMuPGOSBqIbNSDdfJTzwH1XWdw6XIhq2BGEo0pgRJFpSMUT8 Vt9KH7QlFZ9uYNiuCM+uFcv2fKpSkUqDL8oF+R33GX2j+USHgWCgDceH+xQ8WGaiKYks pt5BuG4EeSx4wPf83AiEQOvGCG5URJAHA9hO2fymkW5qewUNhtbQwQcOtxRDJ0paC0Rd HALA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719801985; x=1720406785; 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=7uk0+/ouRfw5Hh1qNoz0AFZnn50xl2En+npPSW4GWrk=; b=qjjtGFBClqDk6Y80Kg9OpaUEauQLpp9CX4W8Tqwz+1Lft4tBMbXPeMu3XazJTGehBY ZeWne6yB8CouV/3rpIcJpTFuwqUC8QjaGHJeIkpkTr/apt/sAmivBppCnRtvH8SAOwpi 0QRAp4VDt9Vx1vIo9eimPV6yBP9gQBgl1600wo4424OjMcyHJ7NqJdBO/sl1KhdxlHZT Cog5xd4N/vQX1+4iKpGLPskzg0zmApcifk9aE8hDQPAva+EIix3y8HW7Dh89uD6svk0o MhInwR9mRJjofyg4Nm/6pwNRf18f6fJ4cza971AtDqByuZkeAENxu5jU1Io/6uxPGyX5 gzlA== X-Gm-Message-State: AOJu0YytujimTRW2pTytmpcuStMWBrfkWGbLI5PinD8UzjyPgk7qzVpY lIJBQidkkI5pldf0EAy3dnzSI/i853GPa7QgbtIOSlmzTkSsxn9bfZtKAoDf4VR8A9BI5AfcnVY / X-Received: by 2002:a05:6a20:7343:b0:1be:cc4c:c386 with SMTP id adf61e73a8af0-1bef611c644mr6720067637.22.1719801984947; Sun, 30 Jun 2024 19:46:24 -0700 (PDT) Received: from stoup.. (174-21-76-141.tukw.qwest.net. [174.21.76.141]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2c91ce6f6cbsm5549885a91.29.2024.06.30.19.46.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Jun 2024 19:46:24 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: mark.cave-ayland@ilande.co.uk, alex.bennee@linaro.org, qemu-stable@nongnu.org Subject: [PATCH] tcg/optimize: Fix TCG_COND_TST* simplification of setcond2 Date: Sun, 30 Jun 2024 19:46:23 -0700 Message-Id: <20240701024623.1265028-1-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42a; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42a.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 Fix a typo in the argument movement. 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 --- tcg/optimize.c | 2 +- tests/tcg/x86_64/test-2413.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 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..a0e4d25093 --- /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) +{ + 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; +}