From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by sourceware.org (Postfix) with ESMTPS id 7F0C6385800C for ; Fri, 16 Feb 2024 17:48:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7F0C6385800C 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 7F0C6385800C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::62f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708105686; cv=none; b=W37GfOteS+EhSq+JTEy6rwhXt9ljEalg+0b7ivaDDQF6jQv7JDNlibEEq57xshSdfr92QTOmNNSSMpHFX41jF9ATP9kw8/+Dvea519F/XJ2l1XAprC+98JYiU++66pCx/4fDicRG6pF9IBzPqDtghgJ840dXizL13xJLBBTD9BQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708105686; c=relaxed/simple; bh=CuqJ9Y2klHrFSnQKdNWROXoN3Wnxuoh1NUOAOs0cGVU=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:From:To; b=EDSKiZcFYSM3qO2LmoBiKNT03f4gjLOVqXI7PME/PDfo9QvHmaRGEl9t2ZcOsOpL9Fqy/JuO6Hz6rUEobo1eMaqE2dWS77ZA2rEjBSwsgEQl5SUT4h5+EEA/8r9THKp8eGa/jEoEh5+9/oF3NsqlILZgaLC9RC6+PwwrkLUppJk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1d71cb97937so24095485ad.3 for ; Fri, 16 Feb 2024 09:48:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708105683; x=1708710483; darn=sourceware.org; h=content-transfer-encoding:in-reply-to:organization:references:to :from:content-language:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=x8MIAThfNSAzfi+EDcBO+UpnmPE87j+rbjf7r9BHQPE=; b=S29v/m5mVRBJ418dzlKmPjHTYNm8oBeitl8scDQNShut3u2989S6Fs+PlFtrQUElkt cTxCMj/b6kxnOksE/AH+NmDBePUtvzcVW20AmAmycFkgg2Pk7pyI8/02CudmgkqhO79Y 3olA4i1KJum1Dk2fX74MOF3I2xkf9gUNJzFT0dNoDKzCP1MrHRR5w1UAqvrrVkDtTQvU SXr88c34AISGZg5I4mqwJ+HwRYtSE/hrxFaxgCdMXdLdkt4Jb4qVxlYuZTsDGvZ0qVLZ IXfpZ4V7nUVyLZC6PD+6d9vjUvm87c5HZO+KWwG3oTNXaccrBhPr66KJecX8YWSorhAE jksw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708105683; x=1708710483; h=content-transfer-encoding:in-reply-to:organization:references:to :from:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=x8MIAThfNSAzfi+EDcBO+UpnmPE87j+rbjf7r9BHQPE=; b=TWet37FEFHHPYE/vVPIiMOfaEH2qpoN95FZlNQjQCXvgTGE2npeiki75w8BSr3/3Zl zvvnEsCeSlrNCl0qRpKq8FAMmPB7Q90fXGyuB+9XoXM52nuuPRQpZKANIg+5enMz8muZ cMEyboYPk9DpNmU0ZLyTTARNUxZKgS3cSjT+JEjsqd4+aP2nQtYfhNRRB42HoZKYAmRN pDQnmUQMiyt6P5f0g1IkL5pCRWRgLTpqAoH9pmp19Qt9N8n6ELTjfiJyJic5Uvat5DtR yQ366zR1jmMmdQ7h6+2RWdqRb7g6wh7edMVzgN7+II/tz8aKF+CTiuaILYwxnv8RBK7g STcQ== X-Gm-Message-State: AOJu0Yw6s+/wa7blzuV5eT8HBwqHNYEQzLj2xrw1up7YNohr3XtFI83/ E6jJa5uhcWJFv8MEZ7ggjoionSlbhNamenCTlgNeoZK0591hIs99OX0g0EdIohoY4qISm97LD5y J X-Google-Smtp-Source: AGHT+IHrfn+BSwo4viN0bSaX7rn+TncnhCapC+AaiAFWt+Uja+Flf/GH/eclxui4emJMRtNBYaEdwQ== X-Received: by 2002:a17:902:e843:b0:1db:ba1c:1b99 with SMTP id t3-20020a170902e84300b001dbba1c1b99mr1253939plg.37.1708105682887; Fri, 16 Feb 2024 09:48:02 -0800 (PST) Received: from ?IPV6:2804:1b3:a7c0:8177:542a:9f26:15a9:5ce4? ([2804:1b3:a7c0:8177:542a:9f26:15a9:5ce4]) by smtp.gmail.com with ESMTPSA id u6-20020a170902b28600b001db9cae20a5sm127032plr.289.2024.02.16.09.48.01 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 16 Feb 2024 09:48:02 -0800 (PST) Message-ID: Date: Fri, 16 Feb 2024 14:47:59 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 00/12] Improve rounding to interger function for C23 Content-Language: en-US From: Adhemerval Zanella Netto To: libc-alpha@sourceware.org References: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> Organization: Linaro In-Reply-To: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_NUMSUBJECT,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Ping. On 28/12/23 14:20, Adhemerval Zanella wrote: > As indicated by GCC documentation [1], ISO C23 does not allow that C > bindings ceil, floor, round, and trunc (in all floating point formats) > to raise > inexact exceptions (different than ISO C99/C11 where this is allowed). > > A recent MIPS patch to used some arch-specific instructions raised this > issue [1] and it was not caught because there was no proper testing. By > adding the missing tests, some implementations do indeed raise inexact > exceptions. > > The generic implementation all uses integer operation, so they are not > subject to this issue. The powerpc (for power4 and lower) and the riscv > avoid the inexact exception by disabling/enabling exceptions. The x86 > uses some arch-specific implementation for long double and on i386 (due > to the use of x87 instruction). > > Instead of adding newer symbols depending on the required standard > version, the patchset adapts the faulty ones to avoid raising the > inexact exception. The x86 version already saves/restore the floating > point status, so I think it is unlikely the patch would yield much > performance difference (I did not do any performance analysis on whether > a generic implementation would yield better performance). > > I checked on powerpc, powerpc64, aarch64, armhf, x86, and did some > regression checks on riscv. > > [1] https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#index-fno-fp-int-builtin-inexact > [2] https://sourceware.org/pipermail/libc-alpha/2023-December/153528.html > > Adhemerval Zanella (12): > math: Reformat Makefile. > powerpc: Add missing arch flags on rounding ifunc variants > math: Add test to check if ceil raise inexact floating-point exception > math: Add test to check if floor raise inexact floating-point > exception > math: Add test to check if trunc raise inexact floating-point > exception > math: Add test to check if round raise inexact floating-point > exception > x86: Do not raise inexact exception on ceill > x86: Do not raise inexact exception on floorl > x86: Do not raise inexact exception on truncl > x86: Do not raise inexact exception on floor/floorf > i386: Do not raise inexact exception on ceil/ceilf > i386: Do not raise inexact exception on trunc/truncf > > math/Makefile | 861 ++++++++++++++---- > math/test-ceil-except-2.c | 67 ++ > math/test-ceil-except.c | 85 ++ > math/test-floor-except-2.c | 67 ++ > math/test-floor-except.c | 85 ++ > math/test-round-except-2.c | 67 ++ > math/test-round-except.c | 85 ++ > math/test-trunc-except-2.c | 67 ++ > math/test-trunc-except.c | 85 ++ > sysdeps/i386/fpu/s_ceil.S | 34 - > sysdeps/i386/fpu/s_ceil.c | 38 + > sysdeps/i386/fpu/s_ceilf.S | 34 - > sysdeps/i386/fpu/s_ceilf.c | 38 + > sysdeps/i386/fpu/s_ceill.S | 39 - > sysdeps/i386/fpu/s_floor.S | 34 - > sysdeps/i386/fpu/s_floor.c | 38 + > sysdeps/i386/fpu/s_floorf.S | 34 - > sysdeps/i386/fpu/s_floorf.c | 38 + > sysdeps/i386/fpu/s_floorl.S | 39 - > sysdeps/i386/fpu/{s_trunc.S => s_trunc.c} | 37 +- > sysdeps/i386/fpu/{s_truncf.S => s_truncf.c} | 37 +- > .../powerpc32/power4/fpu/multiarch/Makefile | 6 + > .../fpu/s_truncl.S => x86/fpu/s_ceill.c} | 38 +- > sysdeps/x86/fpu/s_floorl.c | 38 + > .../fpu/s_truncl.S => x86/fpu/s_truncl.c} | 40 +- > sysdeps/x86_64/fpu/s_ceill.S | 34 - > sysdeps/x86_64/fpu/s_floorl.S | 33 - > 27 files changed, 1583 insertions(+), 515 deletions(-) > create mode 100644 math/test-ceil-except-2.c > create mode 100644 math/test-ceil-except.c > create mode 100644 math/test-floor-except-2.c > create mode 100644 math/test-floor-except.c > create mode 100644 math/test-round-except-2.c > create mode 100644 math/test-round-except.c > create mode 100644 math/test-trunc-except-2.c > create mode 100644 math/test-trunc-except.c > delete mode 100644 sysdeps/i386/fpu/s_ceil.S > create mode 100644 sysdeps/i386/fpu/s_ceil.c > delete mode 100644 sysdeps/i386/fpu/s_ceilf.S > create mode 100644 sysdeps/i386/fpu/s_ceilf.c > delete mode 100644 sysdeps/i386/fpu/s_ceill.S > delete mode 100644 sysdeps/i386/fpu/s_floor.S > create mode 100644 sysdeps/i386/fpu/s_floor.c > delete mode 100644 sysdeps/i386/fpu/s_floorf.S > create mode 100644 sysdeps/i386/fpu/s_floorf.c > delete mode 100644 sysdeps/i386/fpu/s_floorl.S > rename sysdeps/i386/fpu/{s_trunc.S => s_trunc.c} (61%) > rename sysdeps/i386/fpu/{s_truncf.S => s_truncf.c} (61%) > rename sysdeps/{x86_64/fpu/s_truncl.S => x86/fpu/s_ceill.c} (57%) > create mode 100644 sysdeps/x86/fpu/s_floorl.c > rename sysdeps/{i386/fpu/s_truncl.S => x86/fpu/s_truncl.c} (61%) > delete mode 100644 sysdeps/x86_64/fpu/s_ceill.S > delete mode 100644 sysdeps/x86_64/fpu/s_floorl.S >