Auto merge of #128250 - Amanieu:select_unpredictable, r=nikic
Add `select_unpredictable` to force LLVM to use CMOV Since https://reviews.llvm.org/D118118, LLVM will no longer turn CMOVs into branches if it comes from a `select` marked with an `unpredictable` metadata attribute. This PR introduces `core::intrinsics::select_unpredictable` which emits such a `select` and uses it in the implementation of `binary_search_by`.
This commit is contained in:
commit
710ce90fbe
7 changed files with 107 additions and 1 deletions
|
@ -1355,6 +1355,16 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn set_unpredictable(&mut self, inst: &'ll Value) {
|
||||
unsafe {
|
||||
llvm::LLVMSetMetadata(
|
||||
inst,
|
||||
llvm::MD_unpredictable as c_uint,
|
||||
llvm::LLVMMDNodeInContext(self.cx.llcx, ptr::null(), 0),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn minnum(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value {
|
||||
unsafe { llvm::LLVMRustBuildMinNum(self.llbuilder, lhs, rhs) }
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue