The OpenD Programming Language

fastmath

Explicitly sets "fast math" for a function, enabling aggressive math optimizations. These optimizations may dramatically change the outcome of floating point calculations (e.g. because of reassociation).

import ldc.attributes;
alias fastmath = AliasSeq!(llvmAttr("unsafe-fp-math", "true"), llvmFastMathFlag("fast"))

Examples

import ldc.attributes;

@fastmath
double dot(double[] a, double[] b) {
    double s = 0;
    foreach(size_t i; 0..a.length)
    {
        // will result in vectorized fused-multiply-add instructions
        s += a * b;
    }
    return s;
}

Meta