about summary refs log tree commit diff
path: root/src/rustllvm/RustWrapper.cpp
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2016-03-18 21:12:00 -0700
committerbors <bors@rust-lang.org>2016-03-18 21:12:00 -0700
commitb9a93fad92a3411a0e452e339af06703e31c1464 (patch)
tree13908eed4ff2f88c1bf8d1f2f8ca930d6d405aa9 /src/rustllvm/RustWrapper.cpp
parent10bdd808b5e6e23ed8dd9f281c60193a570865f9 (diff)
parent2dbac1fb8ed43cbcd160855803d50a51c38b8cee (diff)
downloadrust-b9a93fad92a3411a0e452e339af06703e31c1464.tar.gz
rust-b9a93fad92a3411a0e452e339af06703e31c1464.zip
Auto merge of #32256 - bluss:float-fast-math, r=alexcrichton
Add intrinsics for float arithmetic with `fast` flag enabled

Add intrinsics for float arithmetic with `fast` flag enabled

`fast` a.k.a UnsafeAlgebra is the flag for enabling all "unsafe"
(according to llvm) float optimizations.

See LangRef for more information http://llvm.org/docs/LangRef.html#fast-math-flags

Providing these operations with less associativity rules (for example)
is useful to numerical applications.

For example, the summation loop:

    let sum = 0.;
    for element in data {
        sum += *element;
    }

Using the default floating point semantics, this loop expresses that the
floats must be added in a sequence, one after another. This constraint
is usually completely unintended, and it means that no auto-vectorization
is possible.
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
-rw-r--r--src/rustllvm/RustWrapper.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/rustllvm/RustWrapper.cpp b/src/rustllvm/RustWrapper.cpp
index 91cf4aa1da9..f488a517b23 100644
--- a/src/rustllvm/RustWrapper.cpp
+++ b/src/rustllvm/RustWrapper.cpp
@@ -164,6 +164,11 @@ extern "C" void LLVMRemoveFunctionAttrString(LLVMValueRef fn, unsigned index, co
                                           to_remove));
 }
 
+// enable fpmath flag UnsafeAlgebra
+extern "C" void LLVMRustSetHasUnsafeAlgebra(LLVMValueRef Instr) {
+    unwrap<Instruction>(Instr)->setHasUnsafeAlgebra(true);
+}
+
 extern "C" LLVMValueRef LLVMBuildAtomicLoad(LLVMBuilderRef B,
                                             LLVMValueRef source,
                                             const char* Name,