From patchwork Wed Jul 26 11:35:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 1813104 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=YkfcewEc; 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 4R9sLD244Qz1yY5 for ; Wed, 26 Jul 2023 21:36:34 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AA39A3857030 for ; Wed, 26 Jul 2023 11:36:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AA39A3857030 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1690371391; bh=73oEp37Ku8utKgo47Us9oOiTH+EZjw01q3xgI4r4luI=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=YkfcewEckIalo8k0cfNsjWJT5UckC+sP4K9+e59YITWlWv+no8PY6NJWe62Z90FsM NrDk94qTFX6N0XId24OT2nmy9Fx55WL0BAOusV/VErGS9ISu7yZ9NZQcfPQObYYBvn +Ut9DfWIU6JjOEy5AC6gpYjVSIhUuqjxRH66Xy0k= 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 09E443858C54 for ; Wed, 26 Jul 2023 11:36:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 09E443858C54 Received: from mimecast-mx02.redhat.com (66.187.233.73 [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-335-IwlEVW_LO-uCxl-HaQO8Ng-1; Wed, 26 Jul 2023 07:36:06 -0400 X-MC-Unique: IwlEVW_LO-uCxl-HaQO8Ng-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6529128237C4 for ; Wed, 26 Jul 2023 11:36:06 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.194.133]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 087FB145414A; Wed, 26 Jul 2023 11:36:05 +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 36QBa2N1097051 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 26 Jul 2023 13:36:03 +0200 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.17.1/8.17.1/Submit) id 36QBZvEl097050; Wed, 26 Jul 2023 13:35:57 +0200 To: GCC patches Cc: Andrew MacLeod , Aldy Hernandez Subject: [COMMITTED] [range-ops] Remove special case for handling bitmasks in casts. Date: Wed, 26 Jul 2023 13:35:54 +0200 Message-ID: <20230726113557.97035-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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" Now that we can generically handle bitmasks for unary operators, there's no need to special case them. gcc/ChangeLog: * range-op-mixed.h (class operator_cast): Add update_bitmask. * range-op.cc (operator_cast::update_bitmask): New. (operator_cast::fold_range): Call update_bitmask. --- gcc/range-op-mixed.h | 2 ++ gcc/range-op.cc | 23 ++++++++--------------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/gcc/range-op-mixed.h b/gcc/range-op-mixed.h index 6944742ecbc..91a4fcc3989 100644 --- a/gcc/range-op-mixed.h +++ b/gcc/range-op-mixed.h @@ -346,6 +346,8 @@ public: relation_kind lhs_op1_relation (const irange &lhs, const irange &op1, const irange &op2, relation_kind) const final override; + void update_bitmask (irange &r, const irange &lh, + const irange &rh) const final override; private: bool truncating_cast_p (const irange &inner, const irange &outer) const; bool inside_domain_p (const wide_int &min, const wide_int &max, diff --git a/gcc/range-op.cc b/gcc/range-op.cc index 6b5d4f2accd..be8f8c48d7c 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -2867,24 +2867,17 @@ operator_cast::fold_range (irange &r, tree type ATTRIBUTE_UNUSED, return true; } - // Update the bitmask. Truncating casts are problematic unless - // the conversion fits in the resulting outer type. - irange_bitmask bm = inner.get_bitmask (); - if (truncating_cast_p (inner, outer) - && wi::rshift (bm.mask (), - wi::uhwi (TYPE_PRECISION (outer.type ()), - TYPE_PRECISION (inner.type ())), - TYPE_SIGN (inner.type ())) != 0) - return true; - unsigned prec = TYPE_PRECISION (type); - signop sign = TYPE_SIGN (inner.type ()); - bm = irange_bitmask (wide_int::from (bm.value (), prec, sign), - wide_int::from (bm.mask (), prec, sign)); - r.update_bitmask (bm); - + update_bitmask (r, inner, outer); return true; } +void +operator_cast::update_bitmask (irange &r, const irange &lh, + const irange &rh) const +{ + update_known_bitmask (r, CONVERT_EXPR, lh, rh); +} + bool operator_cast::op1_range (irange &r, tree type, const irange &lhs,