diff --git a/src/c_wrapper/error.h b/src/c_wrapper/error.h
index 4084eeb2ff898b09d5ee4d084a14d81d6b66807b..6d59bf446ace89395d36bcd52874e68707578302 100644
--- a/src/c_wrapper/error.h
+++ b/src/c_wrapper/error.h
@@ -173,7 +173,7 @@ retry_mem_error(Func func) -> decltype(func())
     try {
         return func();
     } catch (clerror &e) {
-        if (!e.is_out_of_memory() || !py::gc()) {
+        if (PYOPENCL_LIKELY(!e.is_out_of_memory()) || !py::gc()) {
             throw;
         }
     }
diff --git a/src/c_wrapper/memory_object.h b/src/c_wrapper/memory_object.h
index 5f1bb91b6346c79eb563676a0b61ce3322d8e62f..83248b669d87581494b9a082c951372ccbf551eb 100644
--- a/src/c_wrapper/memory_object.h
+++ b/src/c_wrapper/memory_object.h
@@ -33,7 +33,7 @@ public:
     void
     release() const
     {
-        if (!m_valid.exchange(false)) {
+        if (PYOPENCL_UNLIKELY(!m_valid.exchange(false))) {
             throw clerror("MemoryObject.release", CL_INVALID_VALUE,
                           "trying to double-unref mem object");
         }
diff --git a/src/c_wrapper/utils.h b/src/c_wrapper/utils.h
index cf9c4acec177fd982970ad1344c504b5b166eb62..241ef0af008844da52d18c46eba63d2ce8d4c018 100644
--- a/src/c_wrapper/utils.h
+++ b/src/c_wrapper/utils.h
@@ -15,8 +15,8 @@
 #  define PYOPENCL_EXPECT(exp, var) (exp)
 #endif
 
-#define PYOPENCL_LIKELY(x) pyopencl_expect(bool(x), true)
-#define PYOPENCL_UNLIKELY(x) pyopencl_expect(bool(x), false)
+#define PYOPENCL_LIKELY(x) PYOPENCL_EXPECT(bool(x), true)
+#define PYOPENCL_UNLIKELY(x) PYOPENCL_EXPECT(bool(x), false)
 
 template<class T>
 PYOPENCL_USE_RESULT static PYOPENCL_INLINE std::string