| Message ID | 20260803235509.3532030-1-mattst88@gmail.com (mailing list archive) |
|---|---|
| Headers |
Return-Path: <libc-alpha-bounces~patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 218B44BB24EF for <patchwork@sourceware.org>; Mon, 3 Aug 2026 23:55:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 218B44BB24EF Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=LExzc6ko X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-yw1-x1135.google.com (mail-yw1-x1135.google.com [IPv6:2607:f8b0:4864:20::1135]) by sourceware.org (Postfix) with ESMTPS id F2C9F4BB1C29 for <libc-alpha@sourceware.org>; Mon, 3 Aug 2026 23:55:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F2C9F4BB1C29 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org F2C9F4BB1C29 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1135 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1785801313; cv=none; b=vkvmPIPd8UCIayuXll4dwwrybW1QJ3H7eMpsM2rQquXZHDS6rYs6gm2MEVACqOdnE7qMnlBrbvDqdQvW3FRbgB5WcuzSwFjF8zNtDTjmBPhZlyNXrh2ifeuFiTxlKhJX3Rp0dORK2HoQs87zD86awN7Sv/4KOPOiuGHxQsuC5oI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1785801313; c=relaxed/simple; bh=ZzmpypfyyQAF/cV/f3LCsJ5mid9yWWieKJEzA7ug1sA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=aG3cDd38wIpDnzeReA0nNj6YVISn8kqmLz0rq9jtk7kwbbaP4ArOIKGmc0QStv6jY0NltBih+OMgCsm586P1u0eosn9petvh+XRT1BfjAyspkOl6hNeOPw1V8Cb2K1K694p6+VYsDTh16WEUmiUoayN/H++orXLNHN/NSxZKO+Y= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=LExzc6ko DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F2C9F4BB1C29 Received: by mail-yw1-x1135.google.com with SMTP id 00721157ae682-80bb41f7f3cso38988847b3.2 for <libc-alpha@sourceware.org>; Mon, 03 Aug 2026 16:55:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785801312; x=1786406112; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=gOj5WwaK++AKYfJKVJG8ZVvd7wKrdeZQ8H1mHg64QuA=; b=LExzc6koLug4N91+H+vUtw7bucZfBGFUBGzZYdLZpFxXvC4Gdn6BdUPlnQoIcNe8hv EavDuRCSM3VerLvwT5Mp3IjjJM7oWfcv/N7hw7+HHVsOMCC+Y+ObjTUQhClvAhYlntV1 QhfqNIpSqRRjlm6vOsWywgaKTOIVc/AaI0lJfyilErtRmzmvgVAiv9Bm2zflX+lZHVL0 Yp6bNZVFTYbu0XjJ8qUpQd0wM7+6IadcmtHUU7xl1eqSf2UBz8/RQN7oOC2ZGTVyQgRR wF6rwCPOIvtQOzhFUX83Sqft1heDISMecS8VNMuh/Cnul+CETT3S3ciYf4VF2XjrKpbe FcWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785801312; x=1786406112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=gOj5WwaK++AKYfJKVJG8ZVvd7wKrdeZQ8H1mHg64QuA=; b=h+QgZsQef3Si/C62+s4QAaj0c6h9yS4sTDX+NrUOn1myhaASS13CED7ld0kTcIpaSI nKzclVR7xM50syUYDunVqapP6dGR20hSoplkRa6T6RZJyjbzlEUG/fTaN5z+QK07/YEY XupTy9yuoXTz7NUVY9Da2Qm62re8lIKI0jJ2o4azmU5Wn1wm4gzpcR/3cbbPgAYF4SIU jYjxurKOcXI/y58qszlgrA9cDROpUnpxwR4JIFXJaI+LDjEQxSs5AsRnBlPU6z8wMkWb XIWx8SLLvEUkGJMH2RqzVZXbajnxsCVtiaao9UaLOkZO3kxdjuvMQlquXY8O6jw6T1i2 ZrOA== X-Gm-Message-State: AOJu0Yw3118WNQ78GdFt6eTnCL95KBJuIQH4q7zcdOHUGgIXK/ADoUv7 +x7ZVr+qZ7hG7gH9zBtpWRd5XcuhjTuV6G7kEQht0bcUyu6jGRujEkvD0X3qkPIM X-Gm-Gg: AR+sD13eKwGy3wr0jVorWb49mMdsDJODVwhrgQ9WCFKQZmkBDncEFA0BJHD67LhhyHv m3nN7/8Meh9WEcE7T8CP4j7vPIFha1UIxkfHYTuDXo66ZZyGd3HfwagGiHa20u2Cv3p6deVGxqK Iv3iOAKJ0HEaHb/jx8z6isT1+aPaw2FYVZPHg0NQAlignY9/DoXeC9ZCI7zKH1YxhPXMNUOXi2I 8u2U+8EHjI4ekgmQ149NWYOmqr/VluYFwyIdr7rnkXKUDgfOVKyFFlkCa/biarX1YLBEFSZPOzD V2NLaYYTgQ35mkDtadS5WuJkM6N/Uc64+B23uDTqVQo/4NHSfEHvUcF2S4oXjdPHxypp3VpH7nd D8frlkDye2xYLzFJ5ouShezOjBA/Ss5D4lxG4Iq2MPHBc3iSs+mKdhxhdJU8oZthStn1aAAddY2 AWx6cn4savyVfwEHOfalG0QlOex0DRZJ/Dfq2a0nKRN9D8FHVRqkc1TCFGbSTH X-Received: by 2002:a05:690c:9c0f:b0:81e:6a10:f90f with SMTP id 00721157ae682-81fd4b217bfmr152152927b3.17.1785801311914; Mon, 03 Aug 2026 16:55:11 -0700 (PDT) Received: from localhost ([2600:1702:7a90:6f9f:8bc4:8aec:108d:7a04]) by smtp.gmail.com with ESMTPSA id 00721157ae682-81fcd0d6995sm63548187b3.32.2026.08.03.16.55.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Aug 2026 16:55:10 -0700 (PDT) From: Matt Turner <mattst88@gmail.com> To: libc-alpha@sourceware.org Cc: Joseph Myers <josmyers@redhat.com>, Adhemerval Zanella <adhemerval.zanella@linaro.org>, Magnus Lindholm <linmag7@gmail.com> Subject: [PATCH 0/4] Fix underflow signalling for narrowing operations on Alpha Date: Mon, 3 Aug 2026 19:55:05 -0400 Message-ID: <20260803235509.3532030-1-mattst88@gmail.com> X-Mailer: git-send-email 2.54.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list <libc-alpha.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/libc-alpha/> List-Post: <mailto:libc-alpha@sourceware.org> List-Help: <mailto:libc-alpha-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=subscribe> Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org |
| Series |
Fix underflow signalling for narrowing operations on Alpha
|
|
Message
Matt Turner
Aug. 3, 2026, 11:55 p.m. UTC
Four fixes found while getting the math testsuite to pass on Alpha. Two
are generic and two are Alpha specific.
Patches 2 and 3 are the generic ones. A narrowing operation rounds the
exact result once to the narrower type, so it underflows whenever that
result is both tiny and inexact, and two cases were not being signalled.
The first is a result that rounds up to exactly the smallest normal value
of the narrower type. It is not tiny any more once rounded, so an
architecture that determines tininess after rounding does not signal
underflow for it, even though the exact result was tiny. Whether
underflow is due is decided by rounding the round-to-odd value with an
unbounded exponent range, which is what the definition of tininess after
rounding asks for.
The second is a subnormal result, which is tiny by inspection. Its
underflow is normally signalled by the narrowing conversion itself, but
is lost where that conversion is carried out in more than one step: an
intermediate type wide enough to keep the double rounding harmless for
the value can still round to a number the narrower type represents
exactly, leaving the final step exact. This is what happens on Alpha,
where the compiler converts long double to float via double.
Both raises are redundant on architectures that already signal these, and
harmless there. fmaf needs the same treatment, since it computes the
exact result as a double and lets the return convert it.
Patch 1 fixes FE_NOMASK_ENV on Alpha, which omitted the denormal trap
enable bit, so fegetexcept() did not return FE_ALL_EXCEPT. Patch 4 marks
a test as expected to fail, for a case the hardware gets wrong and no
software layer can correct; it depends on patch 2 to fail for the reason
the comment describes.
Tested with a full make check on x86_64, i686, powerpc64, powerpc64le and
sparc64. x86_64 and i686 show no failures at all. powerpc64 and
powerpc64le have one or two failures in malloc and nptl that are
unrelated. sparc64 has one math failure, test-float64x-float128-mul,
which is present identically on an unpatched build of the same commit.
On Alpha the math testsuite goes from 832 failures to 3, though most of
that is due to kernel fixes posted separately to linux-alpha; the two
generic patches here account for 28 of them and fmaf for two more. The
three that remain are a GCC bug: a long double to float cast on Alpha is
lowered as quad to double to float, but C requires it to round once, and
the intermediate can land on a float halfway point.
The ibm128 long double configuration was not tested. The generated test
data carries underflow-ok:arg-ibm128 markers in the cases these patches
touch, so that configuration is worth a look from someone who has one.
Matt Turner (4):
alpha: add the denormal trap enable bit to FE_NOMASK_ENV
math: signal underflow for narrowing results that are tiny before
rounding
math: signal underflow for fmaf results that are tiny before rounding
alpha: expect test-float32x-float64-div to fail
math/math-narrow.h | 130 ++++++++++++++++++-----
sysdeps/alpha/Makefile | 14 +++
sysdeps/alpha/fpu/bits/fenv.h | 2 +-
sysdeps/i386/fpu/s_f32xdivf64.c | 3 +-
sysdeps/i386/fpu/s_f32xmulf64.c | 3 +-
sysdeps/ieee754/dbl-64/s_fadd.c | 3 +-
sysdeps/ieee754/dbl-64/s_fdiv.c | 4 +-
sysdeps/ieee754/dbl-64/s_ffma.c | 4 +-
sysdeps/ieee754/dbl-64/s_fmaf.c | 23 +++-
sysdeps/ieee754/dbl-64/s_fmul.c | 4 +-
sysdeps/ieee754/dbl-64/s_fsub.c | 3 +-
sysdeps/ieee754/ldbl-128/s_daddl.c | 4 +-
sysdeps/ieee754/ldbl-128/s_ddivl.c | 4 +-
sysdeps/ieee754/ldbl-128/s_dfmal.c | 4 +-
sysdeps/ieee754/ldbl-128/s_dmull.c | 4 +-
sysdeps/ieee754/ldbl-128/s_dsubl.c | 4 +-
sysdeps/ieee754/ldbl-128/s_f64xaddf128.c | 4 +-
sysdeps/ieee754/ldbl-128/s_f64xdivf128.c | 5 +-
sysdeps/ieee754/ldbl-128/s_f64xfmaf128.c | 5 +-
sysdeps/ieee754/ldbl-128/s_f64xmulf128.c | 5 +-
sysdeps/ieee754/ldbl-128/s_f64xsubf128.c | 4 +-
sysdeps/ieee754/ldbl-128/s_faddl.c | 4 +-
sysdeps/ieee754/ldbl-128/s_fdivl.c | 4 +-
sysdeps/ieee754/ldbl-128/s_ffmal.c | 4 +-
sysdeps/ieee754/ldbl-128/s_fmull.c | 4 +-
sysdeps/ieee754/ldbl-128/s_fsubl.c | 4 +-
sysdeps/ieee754/ldbl-96/s_daddl.c | 4 +-
sysdeps/ieee754/ldbl-96/s_ddivl.c | 4 +-
sysdeps/ieee754/ldbl-96/s_dfmal.c | 4 +-
sysdeps/ieee754/ldbl-96/s_dmull.c | 4 +-
sysdeps/ieee754/ldbl-96/s_dsubl.c | 4 +-
sysdeps/ieee754/ldbl-96/s_faddl.c | 4 +-
sysdeps/ieee754/ldbl-96/s_fdivl.c | 4 +-
sysdeps/ieee754/ldbl-96/s_ffmal.c | 4 +-
sysdeps/ieee754/ldbl-96/s_fmull.c | 4 +-
sysdeps/ieee754/ldbl-96/s_fsubl.c | 4 +-
sysdeps/x86/fpu/s_ffma.c | 4 +-
37 files changed, 206 insertions(+), 94 deletions(-)