From patchwork Wed Nov 9 07:07:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 60247 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2ADC13841896 for ; Wed, 9 Nov 2022 07:08:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2ADC13841896 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667977717; bh=SRf3fV+Eii5XPbwwOiqLMEwcZGdFMlGJ4XLqKlMIEEE=; 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=yLSryvCf8BqWR8haDmwlRN829RSstr+bIRvbwQLr+PiwuMFnZ184hWGtLmd1FsYkB Fq578xBawPz0iirCqlA+ShfkIjeogGyecdlZtRLmJWSQ22stdmSemxby81htYFGz9k /CGFD2fs6Vz2K0uMNHRXM/VZOXJswnmF+SOYk4c8= 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 6B09A3858D20 for ; Wed, 9 Nov 2022 07:08:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6B09A3858D20 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-131-VscCdXqFNe-g9EHYO6rOqA-1; Wed, 09 Nov 2022 02:08:07 -0500 X-MC-Unique: VscCdXqFNe-g9EHYO6rOqA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 16556886462 for ; Wed, 9 Nov 2022 07:08:07 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.192.190]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BC1A92166B29; Wed, 9 Nov 2022 07:08:06 +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 2A9784Vn1030653 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 9 Nov 2022 08:08:04 +0100 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.17.1/8.17.1/Submit) id 2A9784Qf1030652; Wed, 9 Nov 2022 08:08:04 +0100 To: GCC patches Cc: Jakub Jelinek , Andrew MacLeod , Aldy Hernandez Subject: [COMMITTED] [range-op-float] Implement MINUS_EXPR. Date: Wed, 9 Nov 2022 08:07:58 +0100 Message-Id: <20221109070758.1030615-2-aldyh@redhat.com> In-Reply-To: <20221109070758.1030615-1-aldyh@redhat.com> References: <20221109070758.1030615-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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_H2, 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.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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Now that the generic parts of the binary operators have been abstracted, implementing MINUS_EXPR is a cinch. The op[12]_range entries will be submitted as a follow-up. gcc/ChangeLog: * range-op-float.cc (class foperator_minus): New. (floating_op_table::floating_op_table): Add MINUS_EXPR entry. --- gcc/range-op-float.cc | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/gcc/range-op-float.cc b/gcc/range-op-float.cc index 7075c25442a..d52e971f84e 100644 --- a/gcc/range-op-float.cc +++ b/gcc/range-op-float.cc @@ -1884,6 +1884,29 @@ class foperator_plus : public range_operator_float } fop_plus; +class foperator_minus : public range_operator_float +{ + void rv_fold (REAL_VALUE_TYPE &lb, REAL_VALUE_TYPE &ub, bool &maybe_nan, + tree type, + const REAL_VALUE_TYPE &lh_lb, + const REAL_VALUE_TYPE &lh_ub, + const REAL_VALUE_TYPE &rh_lb, + const REAL_VALUE_TYPE &rh_ub) const final override + { + frange_arithmetic (MINUS_EXPR, type, lb, lh_lb, rh_ub, dconstninf); + frange_arithmetic (MINUS_EXPR, type, ub, lh_ub, rh_lb, dconstinf); + + // [+INF] - [+INF] = NAN + if (real_isinf (&lh_ub, false) && real_isinf (&rh_ub, false)) + maybe_nan = true; + // [-INF] - [-INF] = NAN + else if (real_isinf (&lh_lb, true) && real_isinf (&rh_lb, true)) + maybe_nan = true; + else + maybe_nan = false; + } +} fop_minus; + // Instantiate a range_op_table for floating point operations. static floating_op_table global_floating_table; @@ -1917,6 +1940,7 @@ floating_op_table::floating_op_table () set (ABS_EXPR, fop_abs); set (NEGATE_EXPR, fop_negate); set (PLUS_EXPR, fop_plus); + set (MINUS_EXPR, fop_minus); } // Return a pointer to the range_operator_float instance, if there is