From patchwork Fri Dec 20 04:10:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 852381 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp1853393wrq; Thu, 19 Dec 2024 20:18:20 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCW/uxXF+7mzKJSgwHbzdjf2tHBEPlgLBT7M3tp5of0/rRS62nhbB+9N9Tn1rP5vIiC775+WDg==@linaro.org X-Google-Smtp-Source: AGHT+IHoCVUAHQl4Zfo2oz+p0l+bd3yT8HIM0Twz2VkcGRcX0TjnQUefyVhWN5enOWyVmOTYP0Hc X-Received: by 2002:ad4:5941:0:b0:6d8:99cf:d2d0 with SMTP id 6a1803df08f44-6dd2360e177mr24510406d6.19.1734668300591; Thu, 19 Dec 2024 20:18:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1734668300; cv=none; d=google.com; s=arc-20240605; b=ElH6THVpoIbrS9deawq9ybyjfffjtWyKXy5wM3M74SAbkXuSlVevr+7QRo/dR9pRjr UgFj/CU/nzuYOSa8WqemRecu7JrozgptUr+/CV8f8CHJ4Q+DSH267rt8D/PtBHGrF0A5 QYTAVBc7AkX53EW/Ti9BETgejOYLvkPUUW6DwfGSsdufqKubGXf3AXmMymPhwnAI7E8/ StAQ5BkbYU1p9E6FOoxY7720VXDKrEiTii7iPFKywRgkwIdJmP6p9uViyEzkXf6mbs+e oH3TlId0ethKLJjcE9dtl67vJ8QCHK3MQ4zuBpbzXs/ch+VGR88VxFBj2x3/dQ7V4v80 xklg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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:to:from :dkim-signature; bh=zHRYikYlUcGaNY1VZY67VXJBI/Xxa/TUZTqCG4A2qqU=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=d5fX/dUAVqMoPNT/I3QCxIsXPQ/VBoMoTQacziSGX+Qbzuo9g1nFZ0veT0v5JobMN4 7pTOuJJgCUYHaIbbBDpuhFYj7byg1DT1TohZwxzgMbzZBfSEH2pwLvKBQ/9OWW4IANGt oK1J6EqTeVYXOFf/bsfQ8hx6Y+9BCZ4HcS2ZctffsSaUaU43erZ9OV+gftUqlHaEjliU 3IWfl/qdIhIso/mD/FaV+Cz6iwaKA0J9YcA2LrfODNVFdw8YCuTh/jYcYRo0sORnFEZ2 SWDJ7fl/3iCTosl2BAQcB+6LVsEfFEggUMfsmbns+b25a6shgKmAw3AX7GLidk+el3xx +T8A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FPJMWxhx; 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 6a1803df08f44-6dd18136d73si34074346d6.124.2024.12.19.20.18.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Dec 2024 20:18:20 -0800 (PST) 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=FPJMWxhx; 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 1tOUR5-0003vG-Dv; Thu, 19 Dec 2024 23:16:23 -0500 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 1tOUPN-00010q-TD for qemu-devel@nongnu.org; Thu, 19 Dec 2024 23:14:39 -0500 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tOUPM-0006pI-E1 for qemu-devel@nongnu.org; Thu, 19 Dec 2024 23:14:37 -0500 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-725e71a11f7so2030682b3a.1 for ; Thu, 19 Dec 2024 20:14:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734668075; x=1735272875; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=zHRYikYlUcGaNY1VZY67VXJBI/Xxa/TUZTqCG4A2qqU=; b=FPJMWxhx6//IBm9AMSVJvU6TskweitBpOHpNYz1/anR4t3HL0t428iqBfdGcKYUcZZ XRmIiHGlBo+aXINUap1mUKHFVxd1fwkCRm23TINRpJOa8gQ62RDuhfQjp05pEmXhhny6 9WNJ9R5uLB647DRx0IVSj+qI/DBz4ykONa+xAPWdnXEncvZZvohA9GZKYi5MUO5B2Fmp T7ubLFk1jVi/hKEdRh17PCOwkqaktiojOX6JsGU0Ai/riTTe+oQB/FdHtqPtrZzZ29BR /MUmzOhbbEgBNMPSFyBXOMdJS4cZvaqnGbw+JWePQMLAtW5D+xJccpxPLY3bmrcFNp8V JVVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734668075; x=1735272875; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zHRYikYlUcGaNY1VZY67VXJBI/Xxa/TUZTqCG4A2qqU=; b=IH6J+ml0Gyv97A+PurL99g+/FQdIlPuoDYjS1BCsKUG3Z0uLRudTQGLAv48/XypBzG O4p7YCe9zkJC3sSFVnA7kGLij6ydFw5CpMtzS0wEJYfmS+OL2/m+WLfe+jPobheKzb+L Fa+njOixcVdwMMj6FaTRSJLJTo8q7Mp/nJBCqWcm2Pn9cifjcVIL5r5pfpdWPxBaYxsu 1DnFpXwI2sR/CSUElAO4m1XUX5MmQMtlPSi3cVnfxt7/EFydpQvhOLSEQLGSVrwRpmMJ +lchRoeduT+o+hPIktVVIQ/cuSapzpBz6hyq/I7/SpNLDJm1MqyUMrVsH0KJq+a1p8tS E7ZQ== X-Gm-Message-State: AOJu0YwErfakSGA9SIP9oSh3iXthlVtQ+IrD3Lkv9Bxq3/yYRknjVS8l eXgi/p4FELeAFlqj8qRbNhjQrRiU4rXBWzPwBMgIBhd7l0fAIKQe7UwP2/kNQiNv7emW979woP5 b X-Gm-Gg: ASbGnctpDLG09OGJo5XKMe17/z01D/GAE+LDFmexSc9Hb/Aue1qZaL3g8WyMQbVAWEb RZKHjDSTLDS4L6T7ENnKYtWpXCllqojNBUAKHhJYJOxNDIEm9mspvDmcOLwICnllnpmnSUHGQSN mLIaL3uwMt1IEhZdHPd+q90B5A7l6FduSGxFSJFpzr0AtU1gQgCDnMBUFhQrV+QagIHyDqx9T6q seVyPtXDT73XIp5OBsUgoXETMR4F+/TP3R5/lF6sr477HzErUE9E2DDJaKtnjU= X-Received: by 2002:a05:6a20:7fa6:b0:1e3:c763:74d4 with SMTP id adf61e73a8af0-1e5c6d6b62dmr8829195637.0.1734668074876; Thu, 19 Dec 2024 20:14:34 -0800 (PST) Received: from stoup.. ([71.212.144.252]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-8529e78a55dsm506952a12.80.2024.12.19.20.14.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2024 20:14:34 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 40/51] tcg/optimize: Canonicalize s_mask in fold_exts, fold_sextract Date: Thu, 19 Dec 2024 20:10:52 -0800 Message-ID: <20241220041104.53105-41-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220041104.53105-1-richard.henderson@linaro.org> References: <20241220041104.53105-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::435; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x435.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 Simply or'ing the an input s_mask with the mask implied by the sign extension operation may leave disconnected bits to the right. Use smask_from_smask to canonicalize. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- tcg/optimize.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tcg/optimize.c b/tcg/optimize.c index d0a9ea1ee4..8735dc0c9c 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -1827,6 +1827,7 @@ static bool fold_exts(OptContext *ctx, TCGOp *op) g_assert_not_reached(); } s_mask |= sign << 1; + s_mask = smask_from_smask(s_mask); if (!type_change && fold_affected_mask(ctx, op, s_mask & ~s_mask_old)) { return true; @@ -2534,8 +2535,13 @@ static bool fold_sextract(OptContext *ctx, TCGOp *op) } s_mask_old = t1->s_mask; + /* + * Use the sign mask from the input, force the repetitons from + * the sign extension operation, and canonicalize the result. + */ s_mask = sextract64(s_mask_old, pos, len); s_mask |= MAKE_64BIT_MASK(len, 64 - len); + s_mask = smask_from_smask(s_mask); if (pos == 0 && fold_affected_mask(ctx, op, s_mask & ~s_mask_old)) { return true;