From patchwork Fri Nov 29 13:17:35 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: 846132 Delivered-To: patch@linaro.org Received: by 2002:adf:f2c4:0:b0:382:43a8:7b94 with SMTP id d4csp861486wrp; Fri, 29 Nov 2024 05:31:47 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVyLtMDcip5R/0M6J2TIt+VTNN0KiLlFPyhucLt9U5c+3Pb+I9wddsOKO6rWRlr7yA2KWf74w==@linaro.org X-Google-Smtp-Source: AGHT+IGchfmXIeRLzojlAHEssG/RZhFLA/Wj1GnuhNHgFI5kWyrclSFsDJEm60GZraIAmTdNJdsm X-Received: by 2002:a05:6512:3f1f:b0:53d:d3ff:77f6 with SMTP id 2adb3069b0e04-53df010900cmr7784124e87.46.1732887106874; Fri, 29 Nov 2024 05:31:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1732887106; cv=pass; d=google.com; s=arc-20240605; b=G5X59nNb8JXQu0JnbbgXtezOzhk5EMg7tQBE2E6eagofN2+reY6nYk4Ux7g/Az3QYX Cv3kmqJAqVH7QfTedp8ip+oz3lCidnz0Ag02uIRRJ6X6sEdwnkDojHtYqVbs70pofnE9 4ZZP9jTdhanJsqAkkDAyv8VjtIBWbNz3yj/hoNX+jKlSxMg4jI2TYoIeAP14Jp1jYDyW nSIPP286NVkixak57d/lFcfSMg4abhQhbUK1GiJiOoyvwat93qgJF0ivQzMbzKzyzT1j +Hj+bwRvqjm+sdzCX+FMDSKFsytijk9oTXMSqtfMTQtdna8dqwhlv+HGaEOn1xsCPB7w EIBA== 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:dkim-filter:arc-filter:dmarc-filter :delivered-to:dkim-filter; bh=NNUPxc2XL7gmL6lvkz9xEmSz4KCJR0DVvnDODxlsksc=; fh=/bzLn4Pu6wt5yJOmVA6NJX5WuFMrzV1CRzIGBeRqGpk=; b=NtYVi/19xlDu+VB/G4MnpDDGptkHOgFR+B7nsUKMqoaI0llX14MkBtragBF+KqgCUA xh6f+VEdGlB3oOOjJl6TUEcWjUxQYLnoEwboNGTD/UzKcuRD5fD2QEP+wsgqfuPFPpWm 5x71ltPYovDzvXeS/MufVhmLo1JDAYc8pu8D4NBAPryqTpMT2WJVgQJS5bi5Dwayx1hV taXttFJFaE6Jk95tIjdoUAvBPdBmK6Sq5xOdYqA155EK6xf9cj7+NZaEdf5Z/2dkOFzt EYpQwyqhWSE6oqnh1cVInUiW+83URNe69hCarqLzBMfl0ljuAOfCkuHlgvXKzHGySdYp G3pg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PhTvCtEQ; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 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. [8.43.85.97]) by mx.google.com with ESMTPS id 2adb3069b0e04-53df64963a4si1404228e87.352.2024.11.29.05.31.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Nov 2024 05:31:46 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PhTvCtEQ; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 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 F0F123858CDA for ; Fri, 29 Nov 2024 13:31:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F0F123858CDA 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=PhTvCtEQ X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by sourceware.org (Postfix) with ESMTPS id C85923858CD9 for ; Fri, 29 Nov 2024 13:20:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C85923858CD9 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 C85923858CD9 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::631 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1732886460; cv=none; b=BR5irQpiHnrJwV+gr9jHdjozZ8NvVDkWCUkQBsEHnAAk/HjTe1Bh2ozPXnbPsKn94omLuMm2MfuEhDbHpj5SwxFIIBw/EroqAsogkzhO8TQugYyPWPg8X5pB/gPoiscKeDYB7xTisfkvNd2Utm0NLbaOSz4C4L/6prWarjljlC0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1732886460; c=relaxed/simple; bh=SX9YFqxfrlOCXQIM3bdRENXm8vthDHMgrdzgUchqCFQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=XN2nEB3jVrmTCg+oM0sYuvvrd8m2CW3nfoVyIJnScvXG2JgdxMYIPJyLHO0J1n41FBohaXjxHpq4F3jDVR3oG9niNiEe9p3d6qdtLA1t6PTZuJ3O9jVj9tUIiXsUTx2DMExyEF6J95JALFw8ycUW62Rca63SKRb4Lq3e+gOvXBU= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C85923858CD9 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-2155157c31fso760035ad.1 for ; Fri, 29 Nov 2024 05:20:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1732886458; x=1733491258; 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=NNUPxc2XL7gmL6lvkz9xEmSz4KCJR0DVvnDODxlsksc=; b=PhTvCtEQLwaaubGeRfneHTQMpEI1Z0I2CZTJYfO87tfuh4ORB7tp9cxO3zKLSuSrTR dxonpRSc7aMLajEb3oxO4YgnB9tReSJSQXWvnc0AgfHhyeGFZG62sziwhv02YageToW/ jxirzTdVSBX+WzQZEc33coJI/2CREa7H6fCHhT5YgGg5/izrKgxHHuhmxNf7B2sIsfI8 rU5v4QySgnt5U3Rho0HPKsz3hdhH9r1/CFDzQxGE6Oa8wRBeKVo+sMcdubdUbpiUsiMR 5KijBYi4pvQaeqxOwA3CHkU/1ymHbvvfUKU9mWYur+6lmaAuH3YVwHoEcHwLdN+9WD5Z whrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732886458; x=1733491258; 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=NNUPxc2XL7gmL6lvkz9xEmSz4KCJR0DVvnDODxlsksc=; b=CwypZPOI2Blg+kb3Y1JPCiStPNTCbMrEhNbLGAe0IlB6bb5Kcmkarh3y/m2Fkc9u7O S+LAyHYqVxWEDa/TxKUwncT3az1Hl2v9yDRNJ505MEmyYIaNlO0a9/AB1qb4FUocY2gs S1RZOxFrH3tdxGKnLUSa93/td1aXxn1/n+E6RnChnHWGo5g5K83G0qxXfHXGDIY79+Kk Vb3gzIOsptXhlZ93fMrEADIHcIjx/3GfaSbY8YaNLk1XZ4DcNglqCfYlOeJc+gOYz3ke mTn8kxSGcMA0iZh7uYqvkcK+6gWLK2pRS2p8hLQ7LXWp6JdH/na0Zjgvv+cq+fY47LHw CNzQ== X-Gm-Message-State: AOJu0Yz4EFoj3bLnguLNaPEXSCn5wilSFfUNtb5+ezp/XO57yOU3ojUB v/6tYRAUgnzZSEGgfeRk4htAqato5/FRSYsebxhOPmngn/ZP2FpTa0dsAt0B7uJ9zc66x/7DBq0 syG0R3A== X-Gm-Gg: ASbGncsvsxRqN0UTIXGIrp/h7qmVBi6DbHPGk2BETCqf1n6bNX67G4n0PNQniGlppUF QvwXq7OtBHbTcXsPWR0gLLRCfrzLWYgJWTnlOYPoIqPHQScajd+VIezYawXGVHj6vXJm59NOPvD vg1K7ddZSVUS8F+wGKLFo3MlAnw+Mx2GNJ88VrgRsp+fyDonKaylypwUFGQKMm+ZdKyDfP0qZx6 FMvkzDZE3SCqfnrkxmP9epJ0V74EKg7OVaCUEtIcIa6RxD3PZmp6gZEa660QVY= X-Received: by 2002:a17:902:fc4d:b0:212:38d7:78ea with SMTP id d9443c01a7336-2151d861ac3mr122731895ad.25.1732886458466; Fri, 29 Nov 2024 05:20:58 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c1:68c8:3143:6603:ad16:715e]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2153d5f66d5sm14472255ad.201.2024.11.29.05.20.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Nov 2024 05:20:57 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: DJ Delorie Subject: [PATCH 11/23] math: Add inf support on gen-auto-libm-tests.c Date: Fri, 29 Nov 2024 10:17:35 -0300 Message-ID: <20241129132032.476978-12-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241129132032.476978-1-adhemerval.zanella@linaro.org> References: <20241129132032.476978-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 | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/math/gen-auto-libm-tests.c b/math/gen-auto-libm-tests.c index 0b1e307fae..457610ef04 100644 --- a/math/gen-auto-libm-tests.c +++ b/math/gen-auto-libm-tests.c @@ -981,6 +981,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 +1036,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 +1084,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);