annotate src/fftw-3.3.3/m4/ax_cc_maxopt.m4 @ 155:54abead6ecce

Opus for Windows (MSVC)
author Chris Cannam <cannam@all-day-breakfast.com>
date Fri, 25 Jan 2019 12:15:58 +0000
parents 89f5e221ed7b
children
rev   line source
cannam@95 1 dnl @synopsis AX_CC_MAXOPT
cannam@95 2 dnl @summary turn on optimization flags for the C compiler
cannam@95 3 dnl @category C
cannam@95 4 dnl
cannam@95 5 dnl Try to turn on "good" C optimization flags for various compilers
cannam@95 6 dnl and architectures, for some definition of "good". (In our case,
cannam@95 7 dnl good for FFTW and hopefully for other scientific codes. Modify
cannam@95 8 dnl as needed.)
cannam@95 9 dnl
cannam@95 10 dnl The user can override the flags by setting the CFLAGS environment
cannam@95 11 dnl variable.
cannam@95 12 dnl
cannam@95 13 dnl Note also that the flags assume that ANSI C aliasing rules are
cannam@95 14 dnl followed by the code (e.g. for gcc's -fstrict-aliasing), and that
cannam@95 15 dnl floating-point computations can be re-ordered as needed.
cannam@95 16 dnl
cannam@95 17 dnl Requires macros: AX_CHECK_COMPILER_FLAGS, AX_COMPILER_VENDOR,
cannam@95 18 dnl
cannam@95 19 dnl @version 2011-06-22
cannam@95 20 dnl @license GPLWithACException
cannam@95 21 dnl @author Steven G. Johnson <stevenj@alum.mit.edu> and Matteo Frigo.
cannam@95 22 AC_DEFUN([AX_CC_MAXOPT],
cannam@95 23 [
cannam@95 24 AC_REQUIRE([AC_PROG_CC])
cannam@95 25 AC_REQUIRE([AX_COMPILER_VENDOR])
cannam@95 26 AC_REQUIRE([AC_CANONICAL_HOST])
cannam@95 27
cannam@95 28 # Try to determine "good" native compiler flags if none specified via CFLAGS
cannam@95 29 if test "$ac_test_CFLAGS" != "set"; then
cannam@95 30 CFLAGS=""
cannam@95 31 case $ax_cv_c_compiler_vendor in
cannam@95 32 dec) CFLAGS="-newc -w0 -O5 -ansi_alias -ansi_args -fp_reorder -tune host"
cannam@95 33 ;;
cannam@95 34
cannam@95 35 sun) CFLAGS="-native -fast -xO5 -dalign"
cannam@95 36 ;;
cannam@95 37
cannam@95 38 hp) CFLAGS="+Oall +Optrs_ansi +DSnative"
cannam@95 39 ;;
cannam@95 40
cannam@95 41 ibm) xlc_opt="-qtune=auto"
cannam@95 42 AX_CHECK_COMPILER_FLAGS($xlc_opt,
cannam@95 43 CFLAGS="-O3 -qansialias -w $xlc_opt",
cannam@95 44 [CFLAGS="-O3 -qansialias -w"
cannam@95 45 echo "******************************************************"
cannam@95 46 echo "* You seem to have the IBM C compiler. It is *"
cannam@95 47 echo "* recommended for best performance that you use: *"
cannam@95 48 echo "* *"
cannam@95 49 echo "* CFLAGS=-O3 -qarch=xxx -qtune=xxx -qansialias -w *"
cannam@95 50 echo "* ^^^ ^^^ *"
cannam@95 51 echo "* where xxx is pwr2, pwr3, 604, or whatever kind of *"
cannam@95 52 echo "* CPU you have. (Set the CFLAGS environment var. *"
cannam@95 53 echo "* and re-run configure.) For more info, man cc. *"
cannam@95 54 echo "******************************************************"])
cannam@95 55 ;;
cannam@95 56
cannam@95 57 intel) CFLAGS="-O3"
cannam@95 58 # Intel seems to have changed the spelling of this flag recently
cannam@95 59 icc_ansi_alias="unknown"
cannam@95 60 for flag in -ansi-alias -ansi_alias; do
cannam@95 61 AX_CHECK_COMPILER_FLAGS($flag, [icc_ansi_alias=$flag; break])
cannam@95 62 done
cannam@95 63 if test "x$icc_ansi_alias" != xunknown; then
cannam@95 64 CFLAGS="$CFLAGS $icc_ansi_alias"
cannam@95 65 fi
cannam@95 66 AX_CHECK_COMPILER_FLAGS(-malign-double, CFLAGS="$CFLAGS -malign-double")
cannam@95 67 # We used to check for architecture flags here, e.g. -xHost etc.,
cannam@95 68 # but these flags are problematic. On icc-12.0.0, "-mavx -xHost"
cannam@95 69 # overrides -mavx with -xHost, generating SSE2 code instead of AVX
cannam@95 70 # code. ICC does not seem to support -mtune=host or equivalent
cannam@95 71 # non-ABI changing flag.
cannam@95 72 ;;
cannam@95 73
cannam@95 74 gnu)
cannam@95 75 # Default optimization flags for gcc on all systems.
cannam@95 76 # Somehow -O3 does not imply -fomit-frame-pointer on ia32
cannam@95 77 CFLAGS="-O3 -fomit-frame-pointer"
cannam@95 78
cannam@95 79 # tune for the host by default
cannam@95 80 AX_CHECK_COMPILER_FLAGS(-mtune=native, CFLAGS="$CFLAGS -mtune=native")
cannam@95 81
cannam@95 82 # -malign-double for x86 systems
cannam@95 83 AX_CHECK_COMPILER_FLAGS(-malign-double, CFLAGS="$CFLAGS -malign-double")
cannam@95 84
cannam@95 85 # -fstrict-aliasing for gcc-2.95+
cannam@95 86 AX_CHECK_COMPILER_FLAGS(-fstrict-aliasing,
cannam@95 87 CFLAGS="$CFLAGS -fstrict-aliasing")
cannam@95 88
cannam@95 89 # -fno-schedule-insns is pretty much required on all risc
cannam@95 90 # processors.
cannam@95 91 #
cannam@95 92 # gcc performs one pass of instruction scheduling, then a pass of
cannam@95 93 # register allocation, then another pass of instruction
cannam@95 94 # scheduling. The first pass reorders instructions in a way that
cannam@95 95 # is pretty much the worst possible for the purposes of register
cannam@95 96 # allocation. We disable the first pass.
cannam@95 97 AX_CHECK_COMPILER_FLAGS(-fno-schedule-insns, CFLAGS="$CFLAGS -fno-schedule-insns")
cannam@95 98
cannam@95 99 # note that we enable "unsafe" fp optimization with other compilers, too
cannam@95 100 AX_CHECK_COMPILER_FLAGS(-ffast-math, CFLAGS="$CFLAGS -ffast-math")
cannam@95 101
cannam@95 102 ;;
cannam@95 103 esac
cannam@95 104
cannam@95 105 if test -z "$CFLAGS"; then
cannam@95 106 echo ""
cannam@95 107 echo "********************************************************"
cannam@95 108 echo "* WARNING: Don't know the best CFLAGS for this system *"
cannam@95 109 echo "* Use ./configure CFLAGS=... to specify your own flags *"
cannam@95 110 echo "* (otherwise, a default of CFLAGS=-O3 will be used) *"
cannam@95 111 echo "********************************************************"
cannam@95 112 echo ""
cannam@95 113 CFLAGS="-O3"
cannam@95 114 fi
cannam@95 115
cannam@95 116 AX_CHECK_COMPILER_FLAGS($CFLAGS, [], [
cannam@95 117 echo ""
cannam@95 118 echo "********************************************************"
cannam@95 119 echo "* WARNING: The guessed CFLAGS don't seem to work with *"
cannam@95 120 echo "* your compiler. *"
cannam@95 121 echo "* Use ./configure CFLAGS=... to specify your own flags *"
cannam@95 122 echo "********************************************************"
cannam@95 123 echo ""
cannam@95 124 CFLAGS=""
cannam@95 125 ])
cannam@95 126
cannam@95 127 fi
cannam@95 128 ])