about summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-02-25 09:50:42 +0000
committerbors <bors@rust-lang.org>2024-02-25 09:50:42 +0000
commit02ee5647a25582495d961d375709195f0a7fb5ed (patch)
tree18b2e9a10d6429bea559a3a39bc23363fe446c43 /compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
parent9577051174b9c77ffc4c5b427d90ba49608d5697 (diff)
parent87042866a3c9000cf7ec83a6ed00504a2a00b761 (diff)
downloadrust-02ee5647a25582495d961d375709195f0a7fb5ed.tar.gz
rust-02ee5647a25582495d961d375709195f0a7fb5ed.zip
Auto merge of #3320 - RalfJung:rustup, r=RalfJung
Rustup

Let's see if https://github.com/rust-lang/rust/pull/121114 gets perf back to the old level.
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp')
-rw-r--r--compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
index 7326f2e8e2a..af2353fbb19 100644
--- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
+++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
@@ -450,6 +450,20 @@ extern "C" void LLVMRustSetAlgebraicMath(LLVMValueRef V) {
   }
 }
 
+// Enable the reassoc fast-math flag, allowing transformations that pretend
+// floating-point addition and multiplication are associative.
+//
+// Note that this does NOT enable any flags which can cause a floating-point operation on
+// well-defined inputs to return poison, and therefore this function can be used to build
+// safe Rust intrinsics (such as fadd_algebraic).
+//
+// https://llvm.org/docs/LangRef.html#fast-math-flags
+extern "C" void LLVMRustSetAllowReassoc(LLVMValueRef V) {
+  if (auto I = dyn_cast<Instruction>(unwrap<Value>(V))) {
+    I->setHasAllowReassoc(true);
+  }
+}
+
 extern "C" LLVMValueRef
 LLVMRustBuildAtomicLoad(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Source,
                         const char *Name, LLVMAtomicOrdering Order) {