about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorSean McArthur <sean.monstar@gmail.com>2016-08-31 16:02:55 -0700
committerSean McArthur <sean.monstar@gmail.com>2016-09-02 10:29:32 -0700
commitb778f7fa0192ac6863f3ce0ab49d9c4001bf5503 (patch)
treee462c72b1ce54a3f5e08e2fcb17b47f7d6216b48 /src/libcore
parent824000aee3b9fd594a3da3eb38462fa341f0fa81 (diff)
downloadrust-b778f7fa0192ac6863f3ce0ab49d9c4001bf5503.tar.gz
rust-b778f7fa0192ac6863f3ce0ab49d9c4001bf5503.zip
core: add likely and unlikely intrinsics
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/intrinsics.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs
index 8271b85b01a..619656f4d71 100644
--- a/src/libcore/intrinsics.rs
+++ b/src/libcore/intrinsics.rs
@@ -194,6 +194,20 @@ extern "rust-intrinsic" {
     /// own, or if it does not enable any significant optimizations.
     pub fn assume(b: bool);
 
+    #[cfg(not(stage0))]
+    /// Hints to the compiler that branch condition is likely to be true.
+    /// Returns the value passed to it.
+    ///
+    /// Any use other than with `if` statements will probably not have an effect.
+    pub fn likely(b: bool) -> bool;
+
+    #[cfg(not(stage0))]
+    /// Hints to the compiler that branch condition is likely to be false.
+    /// Returns the value passed to it.
+    ///
+    /// Any use other than with `if` statements will probably not have an effect.
+    pub fn unlikely(b: bool) -> bool;
+
     /// Executes a breakpoint trap, for inspection by a debugger.
     pub fn breakpoint();