[cfe-dev] Floating-point traps on x86-64

Cameron McInally via cfe-dev cfe-dev at lists.llvm.org
Fri Mar 8 07:29:31 PST 2019


On Fri, Mar 8, 2019 at 6:31 AM Dallman, John <john.dallman at siemens.com>
wrote:

> Vlad wrote:
>
> > Unfortunately the LLVM x86 backend has at least one bug that causes FPU
> exceptions on valid FP operations that I know
>
> > of: https://bugs.llvm.org/show_bug.cgi?id=30885
> <https://urldefense.proofpoint.com/v2/url?u=https-3A__bugs.llvm.org_show-5Fbug.cgi-3Fid-3D30885&d=DwMGaQ&c=slrrB7dE8n7gBJbeO0g-IQ&r=O_4M49EtSpZ_-BQYeigzGv0P4__noMcSu2RYEjS1vKs&m=I2CETanc82AaRe9WkqsPsFA3dOIUifqB-6ohqLLl3SQ&s=zB8XJnn86HvBkitTORXzr5lEu3LIjrHczjFDUoGsxXA&e=>.
> You can work around that bug by using -march=haswell, if you continue
>
> > to hit other exceptions you can file LLVM bugs against them, though I'm
> not sure if there is anyone actively interested in
>
> > fixing them.
>
>
>
> I’ll give it a try, although I don’t hold out much hope.
>
>
>
> Cameron wrote:
>
> > This is something we're currently working on. See:
>
> > https://llvm.org/docs/LangRef.html#constrained-floating-point-intrinsics
> <https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_docs_LangRef.html-23constrained-2Dfloating-2Dpoint-2Dintrinsics&d=DwMGaQ&c=slrrB7dE8n7gBJbeO0g-IQ&r=O_4M49EtSpZ_-BQYeigzGv0P4__noMcSu2RYEjS1vKs&m=I2CETanc82AaRe9WkqsPsFA3dOIUifqB-6ohqLLl3SQ&s=UimUOotmvCJf2kFqGqbInmkQx02uML0DQ5XXW_wn_Ik&e=>
>
> > There's still a lot to be done though. Short of this work, I don't think
> you'll find guarantees of trap-safety in LLVM.
>
>
>
> That seems to be saying that trap-safety will be available on those
> intrinsics when they’re complete.
>

That's correct.


> How about expressions written with variables holding doubles and the
> ordinary C arithmetic operators? My chances of getting millions of line of
> code that use those re-written with intrinsics are zero; without that, I’ll
> be forced to turn off floating-point traps if the -march=haswell tweak does
> not help.
>

Those would also be represented as constrained intrinsics. E.g.
llvm.experimental.constrained.fadd. The intrinsics are used to prevent
trap-unsafe optimizations throughout LLVM.

There are some proposals to automatically convert normal IRBuilder calls
into constrained intrinsics. E.g. D53157.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20190308/be835ac9/attachment.html>


More information about the cfe-dev mailing list