NetBSD Problem Report #58326

From www@netbsd.org  Sun Jun  9 14:23:23 2024
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits)
	 client-signature RSA-PSS (2048 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id E8BBF1A9238
	for <gnats-bugs@gnats.NetBSD.org>; Sun,  9 Jun 2024 14:23:22 +0000 (UTC)
Message-Id: <20240609142321.BF2991A923A@mollari.NetBSD.org>
Date: Sun,  9 Jun 2024 14:23:21 +0000 (UTC)
From: campbell+netbsd@mumble.net
Reply-To: campbell+netbsd@mumble.net
To: gnats-bugs@NetBSD.org
Subject: hppa libm is missing fma(3)
X-Send-Pr-Version: www-1.0

>Number:         58326
>Category:       port-hppa
>Synopsis:       hppa libm is missing fma(3)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    port-hppa-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Jun 09 14:25:00 +0000 2024
>Last-Modified:  Sun Jun 09 15:10:01 +0000 2024
>Originator:     Taylor R Campbell
>Release:        current, 10, 9, ...
>Organization:
The NetBSD/hppa Fmadation
>Environment:
>Description:
libm on hppa is missing the fma(3) fused multiply-add functions.  They're not defined as static inlines or builtins by the header file and they're not defined as symbols in libm.
>How-To-Repeat:
$ cat fma.c
#include <math.h>
#include <stdio.h>

volatile double x = 3, y = 4, z = 5;

int
main(void)
{

	printf("%a\n", fma(x, y, z));
	fflush(stdout);
	return ferror(stdout);
}
$ /home/riastradh/netbsd/current/obj.hppa/tooldir/bin/hppa--netbsd-gcc -g -O2 --sysroot=/home/riastradh/netbsd/current/obj.hppa/destdir.hppa   -o fma fma.c 
/home/riastradh/netbsd/current/obj.hppa/tooldir/bin/../lib/gcc/hppa--netbsd/10.5.0/../../../../hppa--netbsd/bin/ld: /tmp/riastradh/ccczEczb.o: in function `main':
/tmp/riastradh/fma.c:10: undefined reference to `fma'
collect2: error: ld returned 1 exit status

>Fix:
Yes, please!

Probably just a matter of adding

COMMON_SRCS+=	s_fma.c s_fmaf.c s_fmal.c

to src/lib/libm/Makefile but we should also have some automatic tests for fma to verify it worked.

>Audit-Trail:
From: Taylor R Campbell <riastradh@NetBSD.org>
To: gnats-bugs@netbsd.org, netbsd-bugs@NetBSD.org
Cc: 
Subject: Re: port-hppa/58326: hppa libm is missing fma(3)
Date: Sun, 9 Jun 2024 15:05:01 +0000

 Looks like PA-RISC 1.1 doesn't have a fused multiply-add instruction,
 just a confusing FMPYADD which does a multiply and an add at the same
 time but on unrelated inputs, so we'll have to use the portable C
 versions.  (PA-RISC 2.0 has FMPYFADD.)

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2024 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.