Add branch hint to make CSEL generation more reliable

PiperOrigin-RevId: 703295900
diff --git a/upb/mini_table/message.c b/upb/mini_table/message.c
index 2de91b3..964b8c7 100644
--- a/upb/mini_table/message.c
+++ b/upb/mini_table/message.c
@@ -43,7 +43,7 @@
     if (num == number) {
       return &base[mid];
     }
-    if (num < number) {
+    if (UPB_UNPREDICTABLE(num < number)) {
       lo = lo_mid;
     } else {
       hi = hi_mid;
diff --git a/upb/port/def.inc b/upb/port/def.inc
index bdd4d6f..91a37dc 100644
--- a/upb/port/def.inc
+++ b/upb/port/def.inc
@@ -131,6 +131,17 @@
 #define UPB_UNLIKELY(x) (x)
 #endif
 
+#ifdef __has_builtin
+#if __has_builtin(__builtin_expect_with_probability)
+#define UPB_UNPREDICTABLE(x) \
+  __builtin_expect_with_probability((bool)(x), 1, 0.5)
+#else
+#define UPB_UNPREDICTABLE(x) (x)
+#endif
+#else
+#define UPB_UNPREDICTABLE(x) (x)
+#endif
+
 // Macros for function attributes on compilers that support them.
 #if defined(__GNUC__) || defined(__clang__)
 #define UPB_FORCEINLINE __inline__ __attribute__((always_inline)) static
diff --git a/upb/port/undef.inc b/upb/port/undef.inc
index e8df37a..3a882f4 100644
--- a/upb/port/undef.inc
+++ b/upb/port/undef.inc
@@ -24,6 +24,7 @@
 #undef UPB_MALLOC_ALIGN
 #undef UPB_LIKELY
 #undef UPB_UNLIKELY
+#undef UPB_UNPREDICTABLE
 #undef UPB_FORCEINLINE
 #undef UPB_NOINLINE
 #undef UPB_NORETURN