|
Message-ID: <CAH9TF6OC6Xf2VGSjpkDfVU12gRJfue1y-UDK=9rO6RnHtWn-fg@mail.gmail.com> Date: Wed, 28 Aug 2024 18:31:42 +0200 From: Alex Rønne Petersen <alex@...xrp.com> To: Alexander Monakov <amonakov@...ras.ru> Cc: musl@...ts.openwall.com Subject: Re: [PATCH] configure: prevent compilers from turning a * b + c into fma(a, b, c) On Wed, Aug 28, 2024 at 5:53 PM Alexander Monakov <amonakov@...ras.ru> wrote: > > > On Wed, 28 Aug 2024, Alex Rønne Petersen wrote: > > > I've seen Clang do this for expressions in the fma() implementation itself, > > which of course led to infinite recursion. This happened when targeting > > arm-linux-musleabi with full soft float mode and -march=armv8-a. I imagine > > it's possible for GCC to do similar silliness. > > musl passes -std=c99 to the compiler, and in all GCC releases so far* that > disables FMA contraction (as opposed to -std=gnu99 or whichever -std=gnuXX > is enabled by default, where unrestricted contraction is implicitly enabled, > i.e. the non-standard and dangerous -ffp-contract=fast mode). OK, that part can definitely be left out. I only added it for good measure; I haven't actually seen the issue occur with GCC. > > Clang respects #pragma STDC FP_CONTRACT OFF, so that is available as > a smaller hammer than disabling fma across the board. Breaking up > contractable expression in fma*.c will work too. That pragma indeed seems to work. I suppose we could just add it to the fma*() implementations and call it a day? I'm unsure if there are other functions that might be affected by this. > > [*] maybe modulo bugs in old releases where the backend doesn't respect > -ffp-contract=off and which Glibc worked around with -mno-fused-madd. > > Alexander
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.