1 # ===========================================================================
2 # http://autoconf-archive.cryp.to/ax_ext.html
3 # ===========================================================================
11 # Find supported SIMD extensions by requesting cpuid. When an SIMD
12 # extension is found, the -m"simdextensionname" is added to SIMD_FLAGS
13 # (only if compilator support it) (ie : if "sse2" is available "-msse2" is
14 # added to SIMD_FLAGS)
18 # AC_SUBST(SIMD_FLAGS)
22 # HAVE_MMX / HAVE_SSE / HAVE_SSE2 / HAVE_SSE3 / HAVE_SSSE3
27 # 2009-04-23 Mark Asbach <markasbach@users.sourceforge.net<
28 # Renamed cache variables so they adhere naming convention
29 # Corrected M4 quoting for AX_CHECK_COMPILER_FLAGS
33 # Copyright (c) 2008 Christophe Tournayre <turn3r@users.sourceforge.net>
35 # Copying and distribution of this file, with or without modification, are
36 # permitted in any medium without royalty provided the copyright notice
37 # and this notice are preserved.
41 AC_REQUIRE([AX_GCC_X86_CPUID])
43 AX_GCC_X86_CPUID([0x00000001])
44 if test "$ax_cv_gcc_x86_cpuid_0x00000001" != "unknown"; then
45 ecx=`echo $ax_cv_gcc_x86_cpuid_0x00000001 | cut -d ":" -f 3`
46 edx=`echo $ax_cv_gcc_x86_cpuid_0x00000001 | cut -d ":" -f 4`
49 AC_CACHE_CHECK([whether mmx is supported], [ax_cv_have_mmx_ext],
52 if test "$ax_cv_gcc_x86_cpuid_0x00000001" != "unknown"; then
53 if test "$((0x$edx>>23&0x01))" = 1; then
54 ax_cv_have_mmx_ext=yes
59 AC_CACHE_CHECK([whether sse is supported], [ax_cv_have_sse_ext],
62 if test "$ax_cv_gcc_x86_cpuid_0x00000001" != "unknown"; then
63 if test "$((0x$edx>>25&0x01))" = 1; then
64 ax_cv_have_sse_ext=yes
69 AC_CACHE_CHECK([whether sse2 is supported], [ax_cv_have_sse2_ext],
71 ax_cv_have_sse2_ext=no
72 if test "$((0x$edx>>26&0x01))" = 1; then
73 ax_cv_have_sse2_ext=yes
77 AC_CACHE_CHECK([whether sse3 is supported], [ax_cv_have_sse3_ext],
79 ax_cv_have_sse3_ext=no
80 if test "$ax_cv_gcc_x86_cpuid_0x00000001" != "unknown"; then
81 if test "$((0x$ecx&0x01))" = 1; then
82 ax_cv_have_sse3_ext=yes
87 AC_CACHE_CHECK([whether ssse3 is supported], [ax_cv_have_ssse3_ext],
89 ax_cv_have_ssse3_ext=no
90 if test "$ax_cv_gcc_x86_cpuid_0x00000001" != "unknown"; then
91 if test "$((0x$ecx>>9&0x01))" = 1; then
92 ax_cv_have_ssse3_ext=yes
97 if test "$ax_cv_have_mmx_ext" = yes; then
98 AC_DEFINE(HAVE_MMX,,[Support mmx instructions])
99 AX_CHECK_COMPILER_FLAGS([-mmmx], [SIMD_FLAGS="$SIMD_FLAGS -mmmx"], [])
102 if test "$ax_cv_have_sse_ext" = yes; then
103 AC_DEFINE(HAVE_SSE,,[Support SSE (Streaming SIMD Extensions) instructions])
104 AX_CHECK_COMPILER_FLAGS([-msse], [SIMD_FLAGS="$SIMD_FLAGS -msse"], [])
107 if test "$ax_cv_have_sse2_ext" = yes; then
108 AC_DEFINE(HAVE_SSE2,,[Support SSE2 (Streaming SIMD Extensions 2) instructions])
109 AX_CHECK_COMPILER_FLAGS([-msse2], [SIMD_FLAGS="$SIMD_FLAGS -msse2"], [])
112 if test "$ax_cv_have_sse3_ext" = yes; then
113 AC_DEFINE(HAVE_SSE3,,[Support SSE3 (Streaming SIMD Extensions 3) instructions])
114 AX_CHECK_COMPILER_FLAGS([-msse3], [SIMD_FLAGS="$SIMD_FLAGS -msse3"], [])
117 if test "$ax_cv_have_ssse3_ext" = yes; then
118 AC_DEFINE(HAVE_SSSE3,,[Support SSSE3 (Supplemental Streaming SIMD Extensions 3) instructions])