From patchwork Wed Jul 26 08:42:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 1813029 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=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=) 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=gL2wF+LY; dkim-atps=neutral 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 (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4R9nV73zW3z1yYc for ; Wed, 26 Jul 2023 18:43:09 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 87987385773F for ; Wed, 26 Jul 2023 08:43:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 87987385773F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1690360986; bh=z6uCdvS0XLN+6DRrMD2pgbF5fRqvJjUzq8dD9OpT4Vc=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=gL2wF+LYMLLJP/Op8jbNvcneeCSDwvlMrTCp1HO8V9ZI5Gd27xoFTvs0fOM3VVLfB hdKfeDkWaXS/HrPTGrp2wg629CxLJ5ZimU+HG/Ci8n42kIWCas0z3dwjfRtO0DcdM+ lfdavAgmMrTwboCEMMcYWOKWT5xVoGwXGB14r9iU= 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 76F113858C66 for ; Wed, 26 Jul 2023 08:42:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 76F113858C66 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-437-UvxGjKYgPzSssw3Enn5W6Q-1; Wed, 26 Jul 2023 04:42:32 -0400 X-MC-Unique: UvxGjKYgPzSssw3Enn5W6Q-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 453A5101A54E for ; Wed, 26 Jul 2023 08:42:32 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.193.103]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D1E07C2C7D3; Wed, 26 Jul 2023 08:42:31 +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 36Q8gSYx043438 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 26 Jul 2023 10:42:29 +0200 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.17.1/8.17.1/Submit) id 36Q8gSpG043437; Wed, 26 Jul 2023 10:42:28 +0200 To: GCC patches Cc: Andrew MacLeod , Aldy Hernandez Subject: [COMMITTED] [range-ops] Handle bitmasks for unary operators. Date: Wed, 26 Jul 2023 10:42:15 +0200 Message-ID: <20230726084224.43416-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.4 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" It looks like we missed out on bitmasks for unary operators because we were using bit_value_binop exclusively. This patch hands off to bit_value_unop when appropriate, thus allowing us to handle ABS and BIT_NOT_EXPR, and others. Follow-up patches will add the tweaks for the range-ops entries themselves. gcc/ChangeLog: * range-op.cc (update_known_bitmask): Handle unary operators. --- gcc/range-op.cc | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/gcc/range-op.cc b/gcc/range-op.cc index 6b5d4f2accd..d959a3e93dc 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -385,15 +385,29 @@ update_known_bitmask (irange &r, tree_code code, irange_bitmask lh_bits = lh.get_bitmask (); irange_bitmask rh_bits = rh.get_bitmask (); - bit_value_binop (code, sign, prec, &widest_value, &widest_mask, - TYPE_SIGN (lh.type ()), - TYPE_PRECISION (lh.type ()), - widest_int::from (lh_bits.value (), sign), - widest_int::from (lh_bits.mask (), sign), - TYPE_SIGN (rh.type ()), - TYPE_PRECISION (rh.type ()), - widest_int::from (rh_bits.value (), sign), - widest_int::from (rh_bits.mask (), sign)); + switch (get_gimple_rhs_class (code)) + { + case GIMPLE_UNARY_RHS: + bit_value_unop (code, sign, prec, &widest_value, &widest_mask, + TYPE_SIGN (lh.type ()), + TYPE_PRECISION (lh.type ()), + widest_int::from (lh_bits.value (), sign), + widest_int::from (lh_bits.mask (), sign)); + break; + case GIMPLE_BINARY_RHS: + bit_value_binop (code, sign, prec, &widest_value, &widest_mask, + TYPE_SIGN (lh.type ()), + TYPE_PRECISION (lh.type ()), + widest_int::from (lh_bits.value (), sign), + widest_int::from (lh_bits.mask (), sign), + TYPE_SIGN (rh.type ()), + TYPE_PRECISION (rh.type ()), + widest_int::from (rh_bits.value (), sign), + widest_int::from (rh_bits.mask (), sign)); + break; + default: + gcc_unreachable (); + } wide_int mask = wide_int::from (widest_mask, prec, sign); wide_int value = wide_int::from (widest_value, prec, sign);