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: 17361 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp189083wru; Tue, 8 Nov 2022 23:09:01 -0800 (PST) X-Google-Smtp-Source: AMsMyM7PtwTnlaf2qtRsvhTbzFzrz/iBoZHBidvvDPvHfnpY0UbS1vpmQ5Btnh1kBONKWhUE2s/X X-Received: by 2002:a17:907:1b1c:b0:72f:9aac:ee41 with SMTP id mp28-20020a1709071b1c00b0072f9aacee41mr28289723ejc.56.1667977741243; Tue, 08 Nov 2022 23:09:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667977741; cv=none; d=google.com; s=arc-20160816; b=K4PRFWd6HTQ9WyGE+n/VtAQMNQH1b9gobSps/ZVmy8w4wScnRmCl/XlUKn8yvzZi1q vTmy5EYvTYhU8wPsKRyfDLX0k4d69EjjXUtOLPeimtbqPfkej7q2xAjgOnn8EqGBnLZX jfuvOwbaGR+e0B4eRk8hA/rwTdkAYnL19XdabRHuv1Q5cHeGSB7pvOgZqHs7SPeyqMu7 YG1D3vYQnAGfSaF+ZKzTbcdkIRju8aAF/evEs4kXNcLuEJIoTjy9st6tRmYl65orFmnX KzBA6+RuL6oCgD73dYk58d6xvOehWSiaLqwwv4oy4t/dd6WSYfDG4vqDUhsep+V86ney cI4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=SRf3fV+Eii5XPbwwOiqLMEwcZGdFMlGJ4XLqKlMIEEE=; b=tOcbysahqYtT4mO8mSpkSMPScTiHFymeYM3GXwmKwXBcadXRTjJvLu1QDOJpcTxut7 sp0S8wOqsCtFzHlbGNR6uEJYkrLTHTGR3aJSHBSeolCd9HCSkD+dSVJB7xluf99euZfA S080Z6Hs/5OKPjs7GBQlUtxwaOhO75ABdTBEk+lMwdfIkbnEQGh0YB/TC+LTLhUfMYaU C4M9zSq4J4LtNJlwjJTohKU/ScnWN0Ky23qiUECEIrpDxoS7ZohYg9U4TJSrFyxWGfph yHy8qrrVHhXv9jHx9R2sh0LGAsus/y/i+4ZvEqnQj7UtPkmu6xW6skIPqsyoJJIndLeq 36kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=iw7wROaV; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id x14-20020a05640226ce00b00457137b2571si16927647edd.346.2022.11.08.23.09.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Nov 2022 23:09:01 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=iw7wROaV; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BA86C384188F for ; Wed, 9 Nov 2022 07:08:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BA86C384188F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667977731; 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=iw7wROaVwNEe5GfuESdysCtWyehzUBQ1wJWE6NqxIco6sjfWIAmoc9P6i1rEHyU51 n8vt362beb+oaK4yn8jaNx0rB0dpTSLqrPfI1QN2Z4dQfNCu7r32xYAR9GtBTP/Lql p8j4wapC4o671kWue3qJUuHHvkhJcyzoeXCcZhWo= 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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749001427661840134?= X-GMAIL-MSGID: =?utf-8?q?1749001427661840134?= 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