From patchwork Fri Feb 22 13:19:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1046805 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-496892-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="awrqJHW+"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 445X4J1vJcz9s70 for ; Sat, 23 Feb 2019 00:19:23 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:reply-to:references:mime-version :content-type:in-reply-to; q=dns; s=default; b=pQctVmv2hVErlC65R c5ylUySGIQ73pBcw7keP5wrQtgxTFHyLDvnJLB+DXtie/fy/6bjPyKmctQvFalPk pefQxf6iDvb0lnj1w8yjJk83CWehWyJPEmB97osNZUUqAs0Fqb4tSnFI3KtdTjMa AVJ+Yd55WnQ1Fqm3zP9RbEVH4w= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:reply-to:references:mime-version :content-type:in-reply-to; s=default; bh=pkqe7gyaKnHv3BXuCvtR6qi lxtw=; b=awrqJHW+LQ1jNwz2VaZ9XVZVGXHeb2xIA/xl/BxAQ3eovN2qQ+4rB8B qIREAHs0EjANGhFupsHsxOCPw96K5qoQeJfntTu4I8iZ1JIeDep2p3adaU/uEpyj JfWhE62FvwzDpUj1cxG8lJIzaJAKlpAraln2XaaS24BUWpzfgvrY= Received: (qmail 110964 invoked by alias); 22 Feb 2019 13:19:15 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 110919 invoked by uid 89); 22 Feb 2019 13:19:14 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-15.4 required=5.0 tests=BAYES_00, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, KAM_NUMSUBJECT, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:2526 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 22 Feb 2019 13:19:13 +0000 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5D6E5308C216; Fri, 22 Feb 2019 13:19:12 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-116-32.ams2.redhat.com [10.36.116.32]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D70876017B; Fri, 22 Feb 2019 13:19:11 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id x1MDJ9xc016535; Fri, 22 Feb 2019 14:19:10 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id x1MDJ7lo016534; Fri, 22 Feb 2019 14:19:07 +0100 Date: Fri, 22 Feb 2019 14:19:07 +0100 From: Jakub Jelinek To: David Malcolm , Richard Biener Cc: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH] Minimum version of mpfr? (was Re: [PATCH] Fix up norm2 simplification (PR middle-end/88074)), take 2 Message-ID: <20190222131907.GC7611@tucnak> Reply-To: Jakub Jelinek References: <20190212230942.GQ2135@tucnak> <1550785827-10962-1-git-send-email-dmalcolm@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1550785827-10962-1-git-send-email-dmalcolm@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-IsSubscribed: yes On Thu, Feb 21, 2019 at 04:50:27PM -0500, David Malcolm wrote: > gcc/fortran/ChangeLog: > PR middle-end/88074 > * simplify.c (norm2_add_squared): Use mp_exp_t rather than > mpfr_exp_t. I have discussed this with Richard on IRC earlier today, there is another issue that mpfr_regular_p is only 3.0 and later. And he prefers that mp_exp_t over say #if MPFR_VERSION < MPFR_VERSION_NUM(3,0,0) typedef mp_exp_t mpfr_exp_t; #endif So, here is the full patch I'll bootstrap/regtest soon: 2019-02-22 David Malcolm Jakub Jelinek PR middle-end/88074 * simplify.c (norm2_do_sqrt, gfc_simplify_norm2): Use mpfr_number_p && !mpfr_zero_p instead of mpfr_regular_p. (norm2_add_squared): Likewise. Use mp_exp_t rather than mpfr_exp_t. Jakub --- gcc/fortran/simplify.c.jj 2019-02-21 22:20:07.272388243 +0100 +++ gcc/fortran/simplify.c 2019-02-22 11:07:36.093374586 +0100 @@ -6061,8 +6061,8 @@ norm2_add_squared (gfc_expr *result, gfc gfc_set_model_kind (result->ts.kind); int index = gfc_validate_kind (BT_REAL, result->ts.kind, false); - mpfr_exp_t exp; - if (mpfr_regular_p (result->value.real)) + mp_exp_t exp; + if (mpfr_number_p (result->value.real) && !mpfr_zero_p (result->value.real)) { exp = mpfr_get_exp (result->value.real); /* If result is getting close to overflowing, scale down. */ @@ -6076,7 +6076,7 @@ norm2_add_squared (gfc_expr *result, gfc } mpfr_init (tmp); - if (mpfr_regular_p (e->value.real)) + if (mpfr_number_p (e->value.real) && !mpfr_zero_p (e->value.real)) { exp = mpfr_get_exp (e->value.real); /* If e**2 would overflow or close to overflowing, scale down. */ @@ -6117,7 +6117,9 @@ norm2_do_sqrt (gfc_expr *result, gfc_exp if (result != e) mpfr_set (result->value.real, e->value.real, GFC_RND_MODE); mpfr_sqrt (result->value.real, result->value.real, GFC_RND_MODE); - if (norm2_scale && mpfr_regular_p (result->value.real)) + if (norm2_scale + && mpfr_number_p (result->value.real) + && !mpfr_zero_p (result->value.real)) { mpfr_t tmp; mpfr_init (tmp); @@ -6156,7 +6158,9 @@ gfc_simplify_norm2 (gfc_expr *e, gfc_exp result = simplify_transformation_to_scalar (result, e, NULL, norm2_add_squared); mpfr_sqrt (result->value.real, result->value.real, GFC_RND_MODE); - if (norm2_scale && mpfr_regular_p (result->value.real)) + if (norm2_scale + && mpfr_number_p (result->value.real) + && !mpfr_zero_p (result->value.real)) { mpfr_t tmp; mpfr_init (tmp);