From patchwork Wed Dec 4 16:37:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 847303 Delivered-To: patch@linaro.org Received: by 2002:a5d:434d:0:b0:385:e875:8a9e with SMTP id u13csp425966wrr; Wed, 4 Dec 2024 08:49:21 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXJ4ofiZiy072GGQ/12160iz1eZk1vBf3dZwsREU5EdOtUyldfY7/7uiH+KLsUR2wNXXMhadg==@linaro.org X-Google-Smtp-Source: AGHT+IG+6B51jQpor8Dtj/sqmPDlHHOnF2lObjS6pVgE+ySmX7lC6148/9tnpPMcXK9fntjkpjiV X-Received: by 2002:ac8:59cc:0:b0:466:aa32:78fa with SMTP id d75a77b69052e-4670c3dba66mr115971941cf.46.1733330961379; Wed, 04 Dec 2024 08:49:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1733330961; cv=pass; d=google.com; s=arc-20240605; b=Rwmvda7DlE9NUpIVRlEXsg0BZDcFjVliro0TsaWAifCrdGCWcaE7gAkxW9njNQFBNB NgzzCtdKVHg9UWQdS6ypJpPi01ln97s8F9WCQtoDgaUqHNjtv//Pb+CqEESKcvmrJY18 YvL3qEqu7WJwX+Kb1p3Z4yyennT8jqJLTwXIR4E7NDl3XyXLLWiop0du+t1kM8/8GXVq M0FeL8Je6yWIySajCdJwVjI19zMJhtwo+m+eBruE8+WzIUpPBSsocS+VpvABsJ47fyML mQLNNHW9UjXO/J4w92HAT3aGqLVHPvg+Xy5xsmM9J0w0vytp86GCV2Soc9Xgn/KZrGc5 3H1w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=errors-to: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 :from:dkim-signature:arc-filter:dmarc-filter:delivered-to :dkim-filter; bh=78CjJaVhxyQF+hIfSg461tEKETz5GDEszdeZgwj7Jgg=; fh=CmGDM+TcKDkWttUBbuoeyeCWXo3i0fQaJViLknsVw4o=; b=k9RSeM2vNL5aIc3J95uO5SJ4k49cN3GKe4emCus9xjbLwdIjXV4LuH/r5c9G0QOXmN FOcUVhJ18tohs8YDydEPrgZBOY73+LVn9fUWVDLDZR/nH7JJ2QeWzrJFJnQhZTOv1STr cwvMtgr8vM5EbaEOt9jWkkDlgpuH60mJtBaVzUcGOb0/jKTXOvJ2dixfScxtRCzQTcAV WArXbYAb24/Br6x3kssPQB5Bk+32Kq1TfqYRgA2a0SvZeZraUQdSFLxD7LXl1NEaHZla SGyirbSIuXJFQUwzNaAjNUf848RE/PMIvTTsRMhUnOk197Wlzq43LBwrgmSWHJ/vR0Px h7qA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=W1NvrF3u; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="libc-alpha-bounces~patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id af79cd13be357-7b6849b23a8si2052314985a.351.2024.12.04.08.49.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Dec 2024 08:49:21 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.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=@linaro.org header.s=google header.b=W1NvrF3u; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="libc-alpha-bounces~patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B43513858D38 for ; Wed, 4 Dec 2024 16:49:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B43513858D38 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=W1NvrF3u X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by sourceware.org (Postfix) with ESMTPS id 01AD23858D20 for ; Wed, 4 Dec 2024 16:40:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 01AD23858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 01AD23858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::62c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1733330450; cv=none; b=q++h9BXBBAd6ZT3ANShwc9x3G89dmhU/oJVYFPqHCtFx3tlPPfZTUZMSAm++xBApGgQJ1O6Q58pTqELVDTgnxrTPL+xZugLEHKRUfOUhSf6Sdd5DnEAYaICB3T0I5cSFOUw5D9y7tODsfhXaQU7RcZqSNANKgmBCDx9CNHo2O5Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1733330450; c=relaxed/simple; bh=F0UrkJ9wEpxFeSGXjPOUXc7FnbGEq/sH7vnOnV+GmgU=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=rghX0S0KsSp0FAEwJ4ZYM1b20pUSszvWt6oGQsfX3SZqd8APU8BtC65fConf9IP79wL1VaUFybvFdBvYdRRqmz27CaCKEUY4Gz1CBeM/a315Ryrakw7Rs/uAP45bQXF45EzxCZZWeNyU2kehGNkpjLlwULYfm7sR5SP6bYvKOO0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-215ac560292so30697005ad.2 for ; Wed, 04 Dec 2024 08:40:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733330419; x=1733935219; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=78CjJaVhxyQF+hIfSg461tEKETz5GDEszdeZgwj7Jgg=; b=W1NvrF3unN+Vj+vSB3ws/mRG0Gtgauh9rHCmH1Eme2TXeoch+PW9DrOSTM8Wstidd+ in1IjMSMzIbFrzzlWMmbL1CIoMrmmkSrnweWBP+UbBrTOdYvnYrlm8/p4RnUZtnx7tIZ 2ivRVcPGlUxEmMnGeMhcqUHsR2Vr5JFez+qEwMZQPE1ZFeFR4T0CSgEwZgvBBSjknoVc JW8UXwL0SDF19MTwNBVrcz5aASDvzO775JDMSKmwlIFU11kfJ9Ezj4iJPCDcRvrF7cEg luL1mmGJhFZWFVoq0opTL0lAdnF51b7kZMSKYzUPjjxvprRhzr+WuStE6V7uDSSzBuoU qfGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733330419; x=1733935219; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=78CjJaVhxyQF+hIfSg461tEKETz5GDEszdeZgwj7Jgg=; b=mE7TgdVizwQW9HwFyz9tdSbJwM+h+IY4WkoYstv3Oxklc+em4KQEhUMUdpCbyHipag KfvOy7vShz6EQugwk0kr8NNX3GDdDUBYMsg79X7xmgqGFfHNFL2aw2M30FwAoQXhAioZ sP4CnjbZa5EAJwWB1uOt5Rff4hp5rUKyhpv5RHD6OQkzMC3FC4ypBDkEeiGvrIZ53B78 cvjiOwhaPg4Vhhs81J84FdhJy9Okfsp1pmfGjh9Pz3nQvdMwvlsyLdIY9UFh8OpDbLQt LQVIz7tWgXUBfWMagkyZKpq6aNy+irIJk9clGI0vgiK9bO5LhX1GrNuMfWv+s/7ifHL2 Hi/g== X-Gm-Message-State: AOJu0Yx8K7LUDR1NADxywgvY4VgpYGbn4jab9SPdMB6Usm96l7qitTEt JxfIwEers4dxyJUt3/pvLBFRd9RZb459dMdVxX6bAFIkQipUaaP/7zbLtjN86LWCI4sQUqTNfZK Q X-Gm-Gg: ASbGnctS6eWEx3m04v3lO9xGzqA2LiRSwAXM0AucPfVGWK+OqeQcBgeWWELJoENz1Be U722ZDUcDxb2mMNbrS0vhNzZWAP+ijKF+0CPcE7orb13IytJ046EMNvV8fiqsV6n1H5wDa3ffRz Y5xJxHNzPavwjAtlG319PiritYf2vvOx3CBsuIYhLIrt2m9hifeb2A3CaAz10IxQWCVkOgvuoIk iQDmMymxCJ4mRrG9swUSLEreba3Yn44nLawf5sHOtHnlgwHEblt3KrnoIkWeQ== X-Received: by 2002:a17:902:e810:b0:215:9d29:9724 with SMTP id d9443c01a7336-215bd11c71cmr97317395ad.38.1733330418693; Wed, 04 Dec 2024 08:40:18 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c2:2d1:40a3:b587:af7c:a5cd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21521967714sm114029225ad.140.2024.12.04.08.40.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Dec 2024 08:40:18 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: DJ Delorie , Joseph Myers Subject: [PATCH v2 12/25] math: Add inf support on gen-auto-libm-tests.c Date: Wed, 4 Dec 2024 13:37:47 -0300 Message-ID: <20241204163949.1408676-13-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241204163949.1408676-1-adhemerval.zanella@linaro.org> References: <20241204163949.1408676-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patch=linaro.org@sourceware.org For some correctly rounded inputs where infinity might generate a number (like atanf), comparing to a pre-defined constant does not yield the expected result in all roundind modes. The most straightforward way to handle it would be to get the expected result from mpfr, where it handles all the rounding mode. --- math/gen-auto-libm-tests.c | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/math/gen-auto-libm-tests.c b/math/gen-auto-libm-tests.c index 0b1e307fae..a60e0f6ec2 100644 --- a/math/gen-auto-libm-tests.c +++ b/math/gen-auto-libm-tests.c @@ -40,12 +40,14 @@ empty lines. Other lines are test lines, of the form "function input1 input2 - ... [flag1 flag2 ...]". Inputs are either finite real numbers or - integers, depending on the function under test. Real numbers may - be in any form acceptable to mpfr_strtofr (base 0); integers in any - form acceptable to mpz_set_str (base 0). In addition, real numbers - may be certain special strings such as "pi", as listed in the - special_real_inputs array. + ... [flag1 flag2 ...]". Inputs are either finite real numbers, + positive or negative infinite (in the form of "inf" or "-inf"), or + integers, depending on the function under test. Real numbers may be + in any form acceptable to mpfr_strtofr (base 0), infinite may in any + form acceptable to mpfr_set_inf, and integers in any form acceptable + to mpz_set_str (base 0). In addition, real numbers may be certain + special strings such as "pi", as listed in the special_real_inputs + array. Each flag is a flag name possibly followed by a series of ":condition". Conditions may be any of the names of floating-point @@ -981,6 +983,26 @@ special_fill_e_minus_1 (mpfr_t res0, mpfr_t res1, fp_format format) return 2; } +/* Set the precision of RES0 based on FORMAT and initialize as an + infinite number. */ +static size_t +special_fill_inf (mpfr_t res0, mpfr_t res1 __attribute__ ((unused)), + fp_format format) +{ + mpfr_init2 (res0, fp_formats[format].mant_dig); + mpfr_set_inf (res0, 0); + return 1; +} + +static size_t +special_fill_minus_inf (mpfr_t res0, mpfr_t res1 __attribute__ ((unused)), + fp_format format) +{ + mpfr_init2 (res0, fp_formats[format].mant_dig); + mpfr_set_inf (res0, -1); + return 1; +} + /* A special string accepted in input arguments. */ typedef struct { @@ -1016,6 +1038,8 @@ static const special_real_input special_real_inputs[] = { "e", special_fill_e }, { "1/e", special_fill_1_e }, { "e-1", special_fill_e_minus_1 }, + { "inf", special_fill_inf }, + { "-inf", special_fill_minus_inf }, }; /* Given a real number R computed in round-to-zero mode, set the @@ -1062,7 +1086,6 @@ round_real (mpfr_t res[rm_num_modes], unsigned int exc_after[rm_num_modes], mpfr_t r, fp_format format) { - assert (mpfr_number_p (r)); for (rounding_mode m = rm_first_mode; m < rm_num_modes; m++) { mpfr_init2 (res[m], fp_formats[format].mant_dig);