Re: Easiest way to use FMA instruction

2020-01-10 Thread kinke via Digitalmars-d-learn
On Friday, 10 January 2020 at 00:02:52 UTC, Johan wrote: For LDC: [...] Simpler variant: ``` import ldc.intrinsics; ... const result = llvm_fma(a, b, c); ``` This LLVM intrinsic is also used in LDC's Phobos for std.math.fma(); unfortunately, upstream Phobos just has a `real`-version, so

Re: Easiest way to use FMA instruction

2020-01-09 Thread Ben Jones via Digitalmars-d-learn
On Friday, 10 January 2020 at 00:08:44 UTC, Johan wrote: On Friday, 10 January 2020 at 00:02:52 UTC, Johan wrote: [...] You have to tell LDC that you are compiling for a CPU that has FMA capability (otherwise it will insert a call to a "fma" runtime library function that most likely you are

Re: Easiest way to use FMA instruction

2020-01-09 Thread Johan via Digitalmars-d-learn
On Friday, 10 January 2020 at 00:02:52 UTC, Johan wrote: For LDC: ``` double fma(double a, double b, double c) { import ldc.llvmasm; return __irEx!( `declare double @llvm.fma.f64(double %a, double %b, double %c)`, `%r = call double @llvm.fma.f64(double %0,

Re: Easiest way to use FMA instruction

2020-01-09 Thread Johan via Digitalmars-d-learn
On Thursday, 9 January 2020 at 22:50:37 UTC, Ben Jones wrote: On Thursday, 9 January 2020 at 20:57:10 UTC, Ben Jones wrote: What's the easiest way to use the FMA instruction (fused multiply add that has nice rounding properties)? The FMA function in Phobos just does a*b +c which will round

Re: Easiest way to use FMA instruction

2020-01-09 Thread Ben Jones via Digitalmars-d-learn
On Thursday, 9 January 2020 at 20:57:10 UTC, Ben Jones wrote: What's the easiest way to use the FMA instruction (fused multiply add that has nice rounding properties)? The FMA function in Phobos just does a*b +c which will round twice. Do any of the intrinsics libraries include

Easiest way to use FMA instruction

2020-01-09 Thread Ben Jones via Digitalmars-d-learn
What's the easiest way to use the FMA instruction (fused multiply add that has nice rounding properties)? The FMA function in Phobos just does a*b +c which will round twice. Do any of the intrinsics libraries include this? Should I write my own inline ASM?