Skip to content

Commit

Permalink
Set only fast-math flags which don't produce poison
Browse files Browse the repository at this point in the history
  • Loading branch information
saethlin committed Feb 6, 2024
1 parent 11f32b7 commit 03e0aa5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,12 +420,15 @@ extern "C" LLVMAttributeRef LLVMRustCreateMemoryEffectsAttr(LLVMContextRef C,
}
}

// Enable a fast-math flag
// Enable fast-math flags which do not let operations return poison.
//
// https://llvm.org/docs/LangRef.html#fast-math-flags
extern "C" void LLVMRustSetFastMath(LLVMValueRef V) {
if (auto I = dyn_cast<Instruction>(unwrap<Value>(V))) {
I->setFast(true);
I->setHasAllowReassoc(true);
I->setHasAllowContract(true);
I->setHasAllowReciprocal(true);
I->setHasNoSignedZeros(true);
}
}

Expand Down

0 comments on commit 03e0aa5

Please sign in to comment.