<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Sep 22, 2014 at 11:51 AM, Matt Turner <span dir="ltr"><<a href="mailto:mattst88@gmail.com" target="_blank">mattst88@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">---<br>
 src/gallium/include/pipe/p_compiler.h     | 45 +------------------------------<br>
 src/mapi/u_compiler.h                     | 10 -------<br>
 src/mesa/drivers/dri/i915/intel_context.h | 10 -------<br>
 src/util/macros.h                         | 32 ++++++++++++++++++++++<br>
 4 files changed, 33 insertions(+), 64 deletions(-)<br>
<br>
diff --git a/src/gallium/include/pipe/p_compiler.h b/src/gallium/include/pipe/p_compiler.h<br>
index 939fb06..4ed6a4b 100644<br>
--- a/src/gallium/include/pipe/p_compiler.h<br>
+++ b/src/gallium/include/pipe/p_compiler.h<br>
@@ -30,6 +30,7 @@<br>
<br>
<br>
 #include "c99_compat.h" /* inline, __func__, etc. */<br>
+#include "../../../util/macros.h"<br></blockquote><div><br></div><div>Do we really need all those ".."s?  Seems to me like we should add something to Makefile.am instead.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
 #include "p_config.h"<br>
<br>
@@ -204,50 +205,6 @@ void _ReadWriteBarrier(void);<br>
<br>
 #endif<br>
<br>
-<br>
-/* You should use these macros to mark if blocks where the if condition<br>
- * is either likely to be true, or unlikely to be true.<br>
- *<br>
- * This will inform human readers of this fact, and will also inform<br>
- * the compiler, who will in turn inform the CPU.<br>
- *<br>
- * CPUs often start executing code inside the if or the else blocks<br>
- * without knowing whether the condition is true or not, and will have<br>
- * to throw the work away if they find out later they executed the<br>
- * wrong part of the if.<br>
- *<br>
- * If these macros are used, the CPU is more likely to correctly predict<br>
- * the right path, and will avoid speculatively executing the wrong branch,<br>
- * thus not throwing away work, resulting in better performance.<br>
- *<br>
- * In light of this, it is also a good idea to mark as "likely" a path<br>
- * which is not necessarily always more likely, but that will benefit much<br>
- * more from performance improvements since it is already much faster than<br>
- * the other path, or viceversa with "unlikely".<br>
- *<br>
- * Example usage:<br>
- * if(unlikely(do_we_need_a_software_fallback()))<br>
- *    do_software_fallback();<br>
- * else<br>
- *    render_with_gpu();<br>
- *<br>
- * The macros follow the Linux kernel convention, and more examples can<br>
- * be found there.<br>
- *<br>
- * Note that profile guided optimization can offer better results, but<br>
- * needs an appropriate coverage suite and does not inform human readers.<br>
- */<br>
-#ifndef likely<br>
-#  if defined(__GNUC__)<br>
-#    define likely(x)   __builtin_expect(!!(x), 1)<br>
-#    define unlikely(x) __builtin_expect(!!(x), 0)<br>
-#  else<br>
-#    define likely(x)   (x)<br>
-#    define unlikely(x) (x)<br>
-#  endif<br>
-#endif<br>
-<br>
-<br>
 /**<br>
  * Static (compile-time) assertion.<br>
  * Basically, use COND to dimension an array.  If COND is false/zero the<br>
diff --git a/src/mapi/u_compiler.h b/src/mapi/u_compiler.h<br>
index b305beb..3364ecd 100644<br>
--- a/src/mapi/u_compiler.h<br>
+++ b/src/mapi/u_compiler.h<br>
@@ -9,14 +9,4 @@<br>
 #  define INLINE inline<br>
 #endif<br>
<br>
-#ifndef likely<br>
-#  if defined(__GNUC__)<br>
-#    define likely(x)   __builtin_expect(!!(x), 1)<br>
-#    define unlikely(x) __builtin_expect(!!(x), 0)<br>
-#  else<br>
-#    define likely(x)   (x)<br>
-#    define unlikely(x) (x)<br>
-#  endif<br>
-#endif<br>
-<br>
 #endif /* _U_COMPILER_H_ */<br>
diff --git a/src/mesa/drivers/dri/i915/intel_context.h b/src/mesa/drivers/dri/i915/intel_context.h<br>
index fccf821..0f315da 100644<br>
--- a/src/mesa/drivers/dri/i915/intel_context.h<br>
+++ b/src/mesa/drivers/dri/i915/intel_context.h<br>
@@ -95,16 +95,6 @@ extern void intelFallback(struct intel_context *intel, GLbitfield bit,<br>
 #define INTEL_WRITE_FULL  0x2<br>
 #define INTEL_READ        0x4<br>
<br>
-#ifndef likely<br>
-#ifdef __GNUC__<br>
-#define likely(expr) (__builtin_expect(expr, 1))<br>
-#define unlikely(expr) (__builtin_expect(expr, 0))<br>
-#else<br>
-#define likely(expr) (expr)<br>
-#define unlikely(expr) (expr)<br>
-#endif<br>
-#endif<br>
-<br>
 struct intel_sync_object {<br>
    struct gl_sync_object Base;<br>
<br>
diff --git a/src/util/macros.h b/src/util/macros.h<br>
index c65ce8a..db5b31a 100644<br>
--- a/src/util/macros.h<br>
+++ b/src/util/macros.h<br>
@@ -37,6 +37,38 @@<br>
 #  define __builtin_expect(x, y) (x)<br>
 #endif<br>
<br>
+/* You should use these macros to mark if blocks where the if condition<br>
+ * is either likely to be true, or unlikely to be true.<br>
+ *<br>
+ * This will inform human readers of this fact, and will also inform<br>
+ * the compiler, who will in turn inform the CPU.<br>
+ *<br>
+ * CPUs often start executing code inside the if or the else blocks<br>
+ * without knowing whether the condition is true or not, and will have<br>
+ * to throw the work away if they find out later they executed the<br>
+ * wrong part of the if.<br>
+ *<br>
+ * If these macros are used, the CPU is more likely to correctly predict<br>
+ * the right path, and will avoid speculatively executing the wrong branch,<br>
+ * thus not throwing away work, resulting in better performance.<br>
+ *<br>
+ * In light of this, it is also a good idea to mark as "likely" a path<br>
+ * which is not necessarily always more likely, but that will benefit much<br>
+ * more from performance improvements since it is already much faster than<br>
+ * the other path, or viceversa with "unlikely".<br>
+ *<br>
+ * Example usage:<br>
+ * if(unlikely(do_we_need_a_software_fallback()))<br>
+ *    do_software_fallback();<br>
+ * else<br>
+ *    render_with_gpu();<br>
+ *<br>
+ * The macros follow the Linux kernel convention, and more examples can<br>
+ * be found there.<br>
+ *<br>
+ * Note that profile guided optimization can offer better results, but<br>
+ * needs an appropriate coverage suite and does not inform human readers.<br>
+ */<br>
 #ifndef likely<br>
 #  ifdef HAVE___BUILTIN_EXPECT<br>
 #    define likely(x)   __builtin_expect(!!(x), 1)<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.8.5.5<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>