From patchwork Tue Jul 16 23:39:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1961354 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=CjbjA1OC; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WNwY92FDRz1ySl for ; Wed, 17 Jul 2024 09:40:29 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 42304387088B for ; Tue, 16 Jul 2024 23:40:27 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id A6B6238449D0 for ; Tue, 16 Jul 2024 23:40:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A6B6238449D0 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A6B6238449D0 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721173206; cv=none; b=wnIprGmTX5xwpRTyuS2Cc4t5/TczjFq54KsxoLaKCW8NAP86rKSIELXwyS+pFuYPxslBPskSbugp/W8Nf7UUQiyjgmW9M6+dBcbn39R59CgnA8CCii2UQPJBDGmVdLqK1sQoW3CPpio/8P1l4qkg2XmOobFYERvZiIzo1HQutHI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721173206; c=relaxed/simple; bh=/NBe9Hd8XEqaGEK3gQznLUsolz5hzhgen35TPj/O818=; h=DKIM-Signature:Message-ID:Date:MIME-Version:To:From:Subject; b=L1jo/ufdIC0lQhcz5L13vFJfSaPUM5eWwi36MGLQ4SDfzBXtBJURNu/xmhPuKllc1luU91Yapp9uY6DSH0LL7ue351IxkcDHz806CqD9ELaKUg7lIb2f6vUUTDyJGAQiUZXtNhAHm7SH1+UyYXnTUbcc32oSh92jy4KoCps3gjw= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721173204; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=EOXMiB92cHVpSNY25aHRFCvdKk5pgxY6x4Uc4sj852E=; b=CjbjA1OC5rABABuVTpTPAlG6GIMlLMzqV5HxzF07tMtop1PIZW1Gsp4g8b/09OnIn+HNlY yyHucFYkZq0itMQRn7jaJ4qeSTBGWiqEMf+pQtWxOX0bkor0AQExBPYjnYGtGh+8nprqR4 dTANXVIhARR+cV3zHYuPEwEbredIX28= Received: from mail-ua1-f71.google.com (mail-ua1-f71.google.com [209.85.222.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-199-uY8RtgbcNpCA3eB5LqFfcA-1; Tue, 16 Jul 2024 19:39:59 -0400 X-MC-Unique: uY8RtgbcNpCA3eB5LqFfcA-1 Received: by mail-ua1-f71.google.com with SMTP id a1e0cc1a2514c-81f331938a1so147549241.0 for ; Tue, 16 Jul 2024 16:39:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721173198; x=1721777998; h=subject:from:cc:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=TdEdpSCjDPIftlQXjRYJWSouvMEfQdewFgcZ7bLycJo=; b=JbUnWltow6uNC+qDJmPYdlq0AAIPLxPastnq+D+n81aKGoXfmj9eUsnf7Cv75WA+DT ReNOEXMU8QYxyTNYoXqjFjBn0ToNQHV6wHxlYgbVXH7BNPQ0ojdkMBlzQ7qxNyyYnkr2 bRkets9mLV7UyE+QO0GnUCbSn9jt6vTEyf0rz5G3y3Slc1UJFVB0IG1GG50CeGUMH1/z JBwERqBu0jjvS/9Mf5qDo6USGkg+yOoBVn2XtzQsiCdVQfHnRXu7c3TMppuY+khCG9BY m3ByMoFDuBMVxVONiDiSo8uNxuSB2gsA3dmsQKdOuz7oKcdK4bbg1PFjr9PjTETCs5nq sQVA== X-Gm-Message-State: AOJu0YyIUhzkJ/quGil9MYv1FAWeoAsJpAma6ENcb9uUuCIDZHT46S1w mEGsXr3ygTPFkdhDL2XpWlNW57OXQKt62lVAKONcaQ/Uo1pafv9vG+mXIND+013ITgL6y0GD/vx y2ZPyQaZYBrtN2RVommu1Z05usHrs+91BYRRoHZfXNuNxoo4C3CFgjql35uBJQZXmgBXA3Vt6NU Rxm/x8ufk570DiSUnvAZX2W2tFzG/X4TWpTz3XV5g= X-Received: by 2002:a05:6102:5e91:b0:48f:8ead:7b7 with SMTP id ada2fe7eead31-491599eaed2mr103256137.21.1721173198290; Tue, 16 Jul 2024 16:39:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF+D/DE5dBY/cMsKSJZKsGOd14mNTkPq1kOZ0pwmq0srtHERS+YFaHeAlLegLYQsbEajZ5BeQ== X-Received: by 2002:a05:6102:5e91:b0:48f:8ead:7b7 with SMTP id ada2fe7eead31-491599eaed2mr103231137.21.1721173197817; Tue, 16 Jul 2024 16:39:57 -0700 (PDT) Received: from ?IPV6:2607:fea8:51de:a700::4ce8? ([2607:fea8:51de:a700::4ce8]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-44f5b7ec1basm40438881cf.34.2024.07.16.16.39.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 16 Jul 2024 16:39:57 -0700 (PDT) Message-ID: Date: Tue, 16 Jul 2024 19:39:55 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: gcc-patches Cc: "hernandez, aldy" From: Andrew MacLeod Subject: [COMMITTED] PR tree-optimization/115951 - range-ops should return the requested boolean type. X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org When PRANGE was created for GCC 15, new range-op entries were created for pointers.  The pointer versions of ==, !=, <, <=, >, >=  use the default boolean type for the result rather than the requested type.   This causes a mismatch later for ADA which has booleans with precision 8 vs the GCC default of precision 1. This patch addresses this oversight by returning a boolean range of the type requested. Bootstrapped on  x86_64-pc-linux-gnu with no regressions. Pushed. Andrew From 8565cb2e22fd116e26aeb9d95030ee0e48d6e6c7 Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Tue, 16 Jul 2024 12:38:11 -0400 Subject: [PATCH] range-ops should return the requested boolean type. The pointer based relation operator's fold_range () routines should return a boolean range with the requested type, not the default type. PR tree-optimization/115951 * range-op-ptr.cc (operator_equal::fold_range): Return a boolean range with the requested type. (operator_not_equal::fold_range): Likewise. (operator_lt::fold_range): Likewise. (operator_le::fold_range): Likewise. (operator_gt::fold_range): Likewise. (operator_ge::fold_range): Likewise. --- gcc/range-op-ptr.cc | 50 ++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/gcc/range-op-ptr.cc b/gcc/range-op-ptr.cc index 1f41236e710..24e206c00cd 100644 --- a/gcc/range-op-ptr.cc +++ b/gcc/range-op-ptr.cc @@ -977,9 +977,9 @@ operator_equal::fold_range (irange &r, tree type, if (op1_const && op2_const) { if (wi::eq_p (op1.lower_bound (), op2.upper_bound())) - r = range_true (); + r = range_true (type); else - r = range_false (); + r = range_false (type); } else { @@ -988,14 +988,14 @@ operator_equal::fold_range (irange &r, tree type, prange tmp = op1; tmp.intersect (op2); if (tmp.undefined_p ()) - r = range_false (); + r = range_false (type); // Check if a constant cannot satisfy the bitmask requirements. else if (op2_const && !op1.get_bitmask ().member_p (op2.lower_bound ())) - r = range_false (); + r = range_false (type); else if (op1_const && !op2.get_bitmask ().member_p (op1.lower_bound ())) - r = range_false (); + r = range_false (type); else - r = range_true_and_false (); + r = range_true_and_false (type); } //update_known_bitmask (r, EQ_EXPR, op1, op2); @@ -1076,9 +1076,9 @@ operator_not_equal::fold_range (irange &r, tree type, if (op1_const && op2_const) { if (wi::ne_p (op1.lower_bound (), op2.upper_bound())) - r = range_true (); + r = range_true (type); else - r = range_false (); + r = range_false (type); } else { @@ -1087,14 +1087,14 @@ operator_not_equal::fold_range (irange &r, tree type, prange tmp = op1; tmp.intersect (op2); if (tmp.undefined_p ()) - r = range_true (); + r = range_true (type); // Check if a constant cannot satisfy the bitmask requirements. else if (op2_const && !op1.get_bitmask ().member_p (op2.lower_bound ())) - r = range_true (); + r = range_true (type); else if (op1_const && !op2.get_bitmask ().member_p (op1.lower_bound ())) - r = range_true (); + r = range_true (type); else - r = range_true_and_false (); + r = range_true_and_false (type); } //update_known_bitmask (r, NE_EXPR, op1, op2); @@ -1173,14 +1173,14 @@ operator_lt::fold_range (irange &r, tree type, gcc_checking_assert (sign == TYPE_SIGN (op2.type ())); if (wi::lt_p (op1.upper_bound (), op2.lower_bound (), sign)) - r = range_true (); + r = range_true (type); else if (!wi::lt_p (op1.lower_bound (), op2.upper_bound (), sign)) - r = range_false (); + r = range_false (type); // Use nonzero bits to determine if < 0 is false. else if (op2.zero_p () && !wi::neg_p (op1.get_nonzero_bits (), sign)) - r = range_false (); + r = range_false (type); else - r = range_true_and_false (); + r = range_true_and_false (type); //update_known_bitmask (r, LT_EXPR, op1, op2); return true; @@ -1266,11 +1266,11 @@ operator_le::fold_range (irange &r, tree type, gcc_checking_assert (sign == TYPE_SIGN (op2.type ())); if (wi::le_p (op1.upper_bound (), op2.lower_bound (), sign)) - r = range_true (); + r = range_true (type); else if (!wi::le_p (op1.lower_bound (), op2.upper_bound (), sign)) - r = range_false (); + r = range_false (type); else - r = range_true_and_false (); + r = range_true_and_false (type); //update_known_bitmask (r, LE_EXPR, op1, op2); return true; @@ -1355,11 +1355,11 @@ operator_gt::fold_range (irange &r, tree type, gcc_checking_assert (sign == TYPE_SIGN (op2.type ())); if (wi::gt_p (op1.lower_bound (), op2.upper_bound (), sign)) - r = range_true (); + r = range_true (type); else if (!wi::gt_p (op1.upper_bound (), op2.lower_bound (), sign)) - r = range_false (); + r = range_false (type); else - r = range_true_and_false (); + r = range_true_and_false (type); //update_known_bitmask (r, GT_EXPR, op1, op2); return true; @@ -1444,11 +1444,11 @@ operator_ge::fold_range (irange &r, tree type, gcc_checking_assert (sign == TYPE_SIGN (op2.type ())); if (wi::ge_p (op1.lower_bound (), op2.upper_bound (), sign)) - r = range_true (); + r = range_true (type); else if (!wi::ge_p (op1.upper_bound (), op2.lower_bound (), sign)) - r = range_false (); + r = range_false (type); else - r = range_true_and_false (); + r = range_true_and_false (type); //update_known_bitmask (r, GE_EXPR, op1, op2); return true; -- 2.45.0