There is modified configrue.ac from rsync:
if test x"$host_cpu" = x"x86_64"; then
if test x"$host_cpu" = x"$build_cpu"; then
AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>
#include <immintrin.h>
/* some long C++ code here */
]], [[if (test_ssse3(42) != 42 || test_sse2(42) != 42 || test_avx2(42) != 42) exit(1);]])],[CXX_OK=yes],[CXX_OK=no])
else
AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[#include <stdio.h>
#include <immintrin.h>
/* the same C++ code again */
]]),[CXX_OK=yes],[CXX_OK=no])
fi
fi
How could this be improved? Is there a way to avoid duplicating C++ code?