|
|
Message-ID: <20260819210559.GJ3542221@port70.net>
Date: Wed, 19 Aug 2026 23:05:59 +0200
From: Szabolcs Nagy <nsz@...t70.net>
To: Rich Felker <dalias@...c.org>
Cc: musl@...ts.openwall.com, Sergey Davidoff <shnatsel@...il.com>
Subject: Re: [PATCH v4 2/2] math: fmaf rewrite
* Rich Felker <dalias@...c.org> [2026-08-19 15:53:43 -0400]:
> On Wed, Aug 19, 2026 at 05:28:28PM +0200, Szabolcs Nagy wrote:
> > + double xy = (double)x * y;
> > + union {double r; uint64_t i;} u = {xy + z};
> > + int e = u.i>>52 & 0x7ff;
> > + /* covers |r| > 0x1p-126 halfway cases (may round incorrectly) */
> > + int halfway = (u.i & 0x1fffffff) == 0x10000000;
> > + /* covers tiny inexact (may miss uflow) and tiny halfway cases */
> > + int tiny = e <= 0x3ff-126 && e >= 0x3ff-149;
> > + if (!halfway && !tiny)
>
> Shouldn't this just be:
>
> if ((!halfway && !tiny) || e == 0x7ff)
>
> so that the rest of the function doesn't have to be conditional? Or am
> I missing something?
yeah that works too.
i was trying to keep the hot path clearly separate
and it was easier to place comments
and i think gcc is also more likely to move the
e==0x7ff check out of the straight line hot path
with my code, so hot code is tighter together.
but it's a bit random what compilers do, so i'm
fine either way.
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.