From patchwork Thu Aug 8 01:43:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 817663 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e11:0:b0:367:895a:4699 with SMTP id p17csp653772wrt; Wed, 7 Aug 2024 18:44:08 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV7B9cf4WwXgsMBknAjY6POAOc/3YOWqEKkgYUf6Dd7Wbt5CA7js4S19y2NKZ2rcRBaQuFIb5cpTQtg2l1BSzN9 X-Google-Smtp-Source: AGHT+IFbe3VTLARdy0HSy4Xr5t4SktyXRdxj2/pYRCHcgyvT4KRbUZnjxwtKURHc0K9b+Y9u5DfD X-Received: by 2002:a05:6214:2d44:b0:6a9:b253:58d5 with SMTP id 6a1803df08f44-6bd6bcc8846mr5149866d6.17.1723081447921; Wed, 07 Aug 2024 18:44:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1723081447; cv=none; d=google.com; s=arc-20160816; b=oy6nVsyRG0qfYUpyeMfFYwqpIr44ORB70ARWhvQQ8eg4rHUdHYeZJg471qPQRr8dnR H0bLwL3Jr4L0EEkdtEx4IXcImN07dyUEXtgLgtxrWyh3L0xVS+o/jb243FjCbG3DBVjg tcw+NXzRbbxI4WBaPEkeJFaA9FQOXQPmYejmYh3ZW7LU9+L0QhWmwNQMoHgOeGTosn8R 9TDlLlEABa5wm3aQghKLZBgj02n7G0XG3ylcOOmYoK+/sFngOZoHsGEiFlk0d+NT2Q5K f0YW9o3KIF7ZO1uDvJCTX5YUI0I2V613pjgQ1gixKhJe30ulhB12DslTBz4AsDzVDceI aCLA== 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=tgUVD11CvGzRcJQDPC2J6X92VppyV08YSDBK35UJlK4=; fh=aYwv1qvAWDHKcZLZyhvLuIoAkBRd6ysYy/Itgr1WhFg=; b=MdKu8vzcFIVQ2ZJM+NsRiFqH/N1Tm23wkGKBN76+sSgl50siq73aIFDeEJeSq5xVwc 8g/sijqEXiWKQWK8S46LvV2DQnNHGvOLK69V+kL7X1uhEA4PGAkZDCw5RcB5K5fWmy0+ 6OMH+pKOHGJLSaO8QDIzCWAC4BUvMSiygmeeWkUr3ARL6+cUO8SJSY+dwy4NLperFUmV FktFj2jBdYyBOBupFfmiFCeWFAz9FqsJDHxkANztkaOA9ROJzm5+Bme/gcdrOS0JueQq 4+ZIYz5hUajkKzloO3UGFyAEjOpO4Cbm8F1sIQqtq1z1yW8hlxFqoQPATOqoz0MZ7t9j MRUQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ARD5YEzE; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-451c870208dsi30356621cf.85.2024.08.07.18.44.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 07 Aug 2024 18:44:07 -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=ARD5YEzE; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sbsBN-0000od-Mq; Wed, 07 Aug 2024 21:43:13 -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 1sbsBM-0000kh-Kg for qemu-devel@nongnu.org; Wed, 07 Aug 2024 21:43:12 -0400 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sbsBK-00082c-T0 for qemu-devel@nongnu.org; Wed, 07 Aug 2024 21:43:12 -0400 Received: by mail-pg1-x534.google.com with SMTP id 41be03b00d2f7-75a6c290528so356664a12.1 for ; Wed, 07 Aug 2024 18:43:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723081389; x=1723686189; 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=tgUVD11CvGzRcJQDPC2J6X92VppyV08YSDBK35UJlK4=; b=ARD5YEzERpyaq6QpeDqYhbmIre88u3i0JWyxlBp5igOoDQyJJ2XmguU0ZacVnVgclE ucvtLq9Ykkj5+lvh0AjR31vQkPv/w3EPQLqohO5iWFv8MBGZZLWuL7vChnQfKNlqK0s8 pmv9DcJQg2U/tHD1/H3D0U3s2vzsi72YoMjeq/9NLMGC5B+dlsnGfbw/i2SsnzyD7rU2 m9DJ0D/zsZZ1oDIQY90syz5acBPivhUtZNdXjhwbNk6XlvSm5Ef+yVcXPf3+5B6ink1B h3lXaDU5jZSFXz1YtD1XqnjEfJrefZHOPkZ7/epVyPIQloDnW2pc0uuqCoaXlcR21gTI skZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723081389; x=1723686189; 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=tgUVD11CvGzRcJQDPC2J6X92VppyV08YSDBK35UJlK4=; b=BAAu9iiQgQA183YJ2TtqlLZqqHPWt49qZZpbePxWTP9dP3Kdv7Yzn3o9++yazFU6rx JytxPcMsupeUzAEwv7qRWRi9gw+OdG2OAv6FRTyfepoB5uH8CusQPMrmVKRi5zj4SNBq IOKzh2wE4ZRLhs8JZoU9P84hdgcdnBinfTJbvAUkdY2lstkDXg4iWe5a3EY7235K4pMh +RqqV6n8fs1y5/exauev4Ftju6N9AbpOWLJvH+jKIpv9LP2V4V4WGSVJcVu3kj4Ren84 /NGiGqDRlG0Byb5Omox/JuJHryDzEqBNn8QeV9r0nhcJg+KYVeImVPHOFE+zzxPQz/av RXGw== X-Gm-Message-State: AOJu0YzUSyHjyi5OB1WILKTs3AI01wy0lfB11qQcese5/Q7vkgWztLwz O8yiHyniYHTFNLIH/6qsG8rdbcZX5Iguq8d41EeMB2By1k0t7mdmqRLvERo7TDPS5/xTo8FALNY NVjU= X-Received: by 2002:a17:902:ced1:b0:1fd:ac9f:4050 with SMTP id d9443c01a7336-200952641a4mr5920075ad.35.1723081389165; Wed, 07 Aug 2024 18:43:09 -0700 (PDT) Received: from stoup.. ([203.30.4.111]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1ff5929abd1sm112724035ad.271.2024.08.07.18.43.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Aug 2024 18:43:08 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 1/1] tcg/ppc: Sync tcg_out_test and constraints Date: Thu, 8 Aug 2024 11:43:00 +1000 Message-ID: <20240808014300.65269-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240808014300.65269-1-richard.henderson@linaro.org> References: <20240808014300.65269-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::534; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x534.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Ensure the code structure is the same for matching constraints and emitting code, lest we allow constants that cannot be trivially tested. Cc: qemu-stable@nongnu.org Fixes: ad788aebbab ("tcg/ppc: Support TCG_COND_TST{EQ,NE}") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2487 Signed-off-by: Richard Henderson Message-Id: <44328324-af73-4439-9d2b-d414e0e13dd7@linaro.org> Reviewed-by: Philippe Mathieu-Daudé --- tcg/ppc/tcg-target.c.inc | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index 7f3829beeb..3553a47ba9 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -325,9 +325,11 @@ static bool tcg_target_const_match(int64_t sval, int ct, if ((uval & ~0xffff) == 0 || (uval & ~0xffff0000ull) == 0) { return 1; } - if (TCG_TARGET_REG_BITS == 32 || type == TCG_TYPE_I32 - ? mask_operand(uval, &mb, &me) - : mask64_operand(uval << clz64(uval), &mb, &me)) { + if (uval == (uint32_t)uval && mask_operand(uval, &mb, &me)) { + return 1; + } + if (TCG_TARGET_REG_BITS == 64 && + mask64_operand(uval << clz64(uval), &mb, &me)) { return 1; } return 0; @@ -1749,8 +1751,6 @@ static void tcg_out_test(TCGContext *s, TCGReg dest, TCGReg arg1, TCGArg arg2, if (type == TCG_TYPE_I32) { arg2 = (uint32_t)arg2; - } else if (arg2 == (uint32_t)arg2) { - type = TCG_TYPE_I32; } if ((arg2 & ~0xffff) == 0) { @@ -1761,12 +1761,11 @@ static void tcg_out_test(TCGContext *s, TCGReg dest, TCGReg arg1, TCGArg arg2, tcg_out32(s, ANDIS | SAI(arg1, dest, arg2 >> 16)); return; } - if (TCG_TARGET_REG_BITS == 32 || type == TCG_TYPE_I32) { - if (mask_operand(arg2, &mb, &me)) { - tcg_out_rlw_rc(s, RLWINM, dest, arg1, 0, mb, me, rc); - return; - } - } else { + if (arg2 == (uint32_t)arg2 && mask_operand(arg2, &mb, &me)) { + tcg_out_rlw_rc(s, RLWINM, dest, arg1, 0, mb, me, rc); + return; + } + if (TCG_TARGET_REG_BITS == 64) { int sh = clz64(arg2); if (mask64_operand(arg2 << sh, &mb, &me)) { tcg_out_rld_rc(s, RLDICR, dest, arg1, sh, me, rc);