From patchwork Fri Jul 7 07:57:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 1804638 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=iW9fWsYP; dkim-atps=neutral Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Qy5QJ3bSHz20ZC for ; Fri, 7 Jul 2023 17:59:20 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 883FE385DC14 for ; Fri, 7 Jul 2023 07:59:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 883FE385DC14 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1688716758; bh=UG2zRQhBoH1qaLKZ6BAQkxong82zDDAKQ3D/yrAdyCc=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=iW9fWsYPLC35poe/H8IeJIXUeRkjGuGOLRK0iFcJ9PeibyPU7iuAohpAa9RkrOVk4 cZzE3Lx13qKGJoi+dKp4nWteu/NRPTpciT6h2k7uZXaj+87LDGBe7lTo1UndaFb0cG hCC3zEB2chTNHGmhjgCaFWPwnBCL1uP/tZcR56tw= 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 878B2385771F for ; Fri, 7 Jul 2023 07:58:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 878B2385771F Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-33-2c9o8C1ZPUaRWtGCBwk8wA-1; Fri, 07 Jul 2023 03:57:59 -0400 X-MC-Unique: 2c9o8C1ZPUaRWtGCBwk8wA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A00003800538 for ; Fri, 7 Jul 2023 07:57:58 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.192.146]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3E5381121330; Fri, 7 Jul 2023 07:57:58 +0000 (UTC) Received: from abulafia.quesejoda.com (localhost [127.0.0.1]) by abulafia.quesejoda.com (8.17.1/8.17.1) with ESMTPS id 3677vuY71248070 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 7 Jul 2023 09:57:57 +0200 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.17.1/8.17.1/Submit) id 3677vu3Y1248069; Fri, 7 Jul 2023 09:57:56 +0200 To: GCC patches Cc: Andrew MacLeod , Aldy Hernandez Subject: [COMMITTED] The caller to irange::intersect (wide_int, wide_int) must normalize the range. Date: Fri, 7 Jul 2023 09:57:49 +0200 Message-Id: <20230707075750.1248045-2-aldyh@redhat.com> In-Reply-To: <20230707075750.1248045-1-aldyh@redhat.com> References: <20230707075750.1248045-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.7 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_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Aldy Hernandez via Gcc-patches From: Aldy Hernandez Reply-To: Aldy Hernandez Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Per the function comment, the caller to intersect(wide_int, wide_int) must handle the mask. This means it must also normalize the range if anything changed. gcc/ChangeLog: * value-range.cc (irange::intersect): Leave normalization to caller. --- gcc/value-range.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gcc/value-range.cc b/gcc/value-range.cc index 8e5607a7eeb..fbc0c7a6f82 100644 --- a/gcc/value-range.cc +++ b/gcc/value-range.cc @@ -1475,6 +1475,8 @@ irange::intersect (const vrange &v) return true; res |= intersect_bitmask (r); + if (res) + normalize_kind (); return res; } @@ -1574,7 +1576,7 @@ irange::intersect (const vrange &v) // Multirange intersect for a specified wide_int [lb, ub] range. // Return TRUE if intersect changed anything. // -// NOTE: It is the caller's responsibility to intersect the nonzero masks. +// NOTE: It is the caller's responsibility to intersect the mask. bool irange::intersect (const wide_int& lb, const wide_int& ub) @@ -1633,7 +1635,8 @@ irange::intersect (const wide_int& lb, const wide_int& ub) } m_kind = VR_RANGE; - normalize_kind (); + // The caller must normalize and verify the range, as the bitmask + // still needs to be handled. return true; }