Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260819152828.GI3542221@port70.net>
Date: Wed, 19 Aug 2026 17:28:28 +0200
From: Szabolcs Nagy <nsz@...t70.net>
To: Rich Felker <dalias@...c.org>
Cc: musl@...ts.openwall.com, Sergey Davidoff <shnatsel@...il.com>
Subject: [PATCH v4 2/2] math: fmaf rewrite

* Rich Felker <dalias@...c.org> [2026-08-19 08:48:19 -0400]:
> On Tue, Aug 18, 2026 at 09:10:35PM +0200, Szabolcs Nagy wrote:
> > round to odd (with sr,st in 0,1):
> > 
> >   if (u%2 == 0)
> >     u += sr == st ? 1 : -1;
> > 
> > can be written as
> > 
> >   u -= sr ^ st;
> >   u |= 1;
> > 
> > compilers don't seem to do this transformation, but then
> > u&0xfffffff can be removed without making the adjust more
> > expensive. this saves some bytes and may only regress
> > subnormal range cases a bit. maybe a better tradeoff.
> 
> Do you want to pursue this or just go with the patch as-is?

i made the change after some benchmarking,
it is hard to justify the larger code and
the trick is not too obscure.

v4:
- branchless round to odd
- updated comments

View attachment "v4-0002-math-fmaf-rewrite.patch" of type "text/x-diff" (5657 bytes)

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.