[Mesa-dev] [PATCH] replace file specific compiler optimization with inline attibute

Marc Dietrich marvin24 at gmx.de
Thu Sep 11 06:58:28 PDT 2014


File specific optimization as used for src/mesa/main/streaming-load-memcpy.c
currently will cause problems with LTO in the future
(see: https://bugs.freedesktop.org/show_bug.cgi?id=83669). Replace it with
in-file target specification.

This only works for gcc for now. The intel compiler has
__attribute__((cpu_specific(cpuid))) with cpuid core_2_duo_sse4_1, but I'm
not sure if mesa compiles with it and how it behaves on different platforms.

Signed-off-by: Marc Dietrich <marvin24 at gmx.de>
---
 src/mesa/Makefile.am                  | 1 -
 src/mesa/main/streaming-load-memcpy.c | 4 ++--
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/mesa/Makefile.am b/src/mesa/Makefile.am
index e71bccb..bbdb36f 100644
--- a/src/mesa/Makefile.am
+++ b/src/mesa/Makefile.am
@@ -152,7 +152,6 @@ libmesagallium_la_LIBADD = \
 
 libmesa_sse41_la_SOURCES = \
 	main/streaming-load-memcpy.c
-libmesa_sse41_la_CFLAGS = $(AM_CFLAGS) -msse4.1
 
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = gl.pc
diff --git a/src/mesa/main/streaming-load-memcpy.c b/src/mesa/main/streaming-load-memcpy.c
index 8427149..94b0e0a 100644
--- a/src/mesa/main/streaming-load-memcpy.c
+++ b/src/mesa/main/streaming-load-memcpy.c
@@ -26,7 +26,7 @@
  *
  */
 
-#ifdef __SSE4_1__
+#ifdef USE_SSE41
 #include "main/macros.h"
 #include "main/streaming-load-memcpy.h"
 #include <smmintrin.h>
@@ -34,7 +34,7 @@
 /* Copies memory from src to dst, using SSE 4.1's MOVNTDQA to get streaming
  * read performance from uncached memory.
  */
-void
+void __attribute__ ((target("sse4.1")))
 _mesa_streaming_load_memcpy(void *restrict dst, void *restrict src, size_t len)
 {
    char *restrict d = dst;
-- 
2.1.0



More information about the mesa-dev mailing list