Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Wed, 2 Dec 2020 11:44:59 +0100
From: Marius Hillenbrand <>
Subject: Re: [PATCH] s390x: derive float_t from compiler or default to

On 12/1/20 9:50 PM, Rich Felker wrote:
> On Tue, Dec 01, 2020 at 03:36:34PM +0100, Marius Hillenbrand wrote:
>> Hi,
>> float_t should represent the type that is used to evaluate float
>> expressions internally. On s390(x), float_t is currently set to double.
>> In contrast, the isa supports single-precision float operations and
>> compilers by default evaluate float in single precision, which violates
>> the C standard (sections and 7.12 in C11/C17). With
>> -fexcess-precision=standard, gcc evaluates float in double precision,
>> which aligns with the standard yet at the cost of added conversion
>> instructions. To improve standards compliance, this patch changes the
>> definition of float_t to be derived from the compiler's
>> The port of glibc to s390 incorrectly deferred to the generic
>> definitions which, back then, tied float_t to double. Since then, this
>> definition has been kept to avoid ABI changes, most recently in the
>> refactoring of float_t into bits/flt-eval-method.h
>> and the discussion around
>> musl apparently adopted the definition from glibc.
>> Given the performance overhead and reduced standards compliance, I have
>> reevaluated cleaning up the special behavior on s390x. I found only two
>> packages, ImageMagick and clucene, that use float_t in their API, out of
>>> 130k Debian source packages scanned. To avoid breaking ABI changes, I
>> patched these packages to avoid their reliance on float_t (in
>> ImageMagick since 7.0.10-39, patch in
>> - patch for
>> clucene in
>> gcc-11 will drop the special case to retrofit double
>> precision behavior for -fexcess-precision=standard so that
>> __FLT_EVAL_METHOD__ will be 0 on s390x in any scenario.
>> glibc 2.33 will most likely adopt the same behavior as in this patch, so
>> that float_t will eventually be float on s390x in any scenario.
>> Testing with libc-test showed no regressions. Failing testcases
>> src/math/lgammaf[_r].exe succeed with the patch.
>> Please review and consider merging this patch.
> Thanks for the detailed report. To be clear, all models/ISA-levels
> support the single-precision ops and future GCC will always use them
> even with -fexcess-precision=standard, but old ones switch to using
> double precision ops with -fexcess-precision=standard to meet the
> contract of evaluating in (old definition of) float_t. Is this
> correct?

Yes, your summary is correct -- with one exception that I omitted in my
original post: future GCC compiled against current libc will still
switch to using double precision ops with -fexcess-precision=standard to
match the old definition of float_t. When future GCC detects a future
libc at compile-time, it will always use single-precision ops. Without
that switch, updating GCC while keeping your current libc would have
worsened the situation wrt the C standard.


Marius Hillenbrand
Linux on Z development
IBM Deutschland Research & Development GmbH
Vors. des Aufsichtsrats: Gregor Pillen / Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht
Stuttgart, HRB 243294

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.