diff options
author | sgehwolf <unknown> | 2019-04-29 14:23:21 +0200 |
---|---|---|
committer | bell-sw <liberica@bell-sw.com> | 2019-07-22 19:21:42 +0300 |
commit | 0817dd2ef1a71f42b9ed5cb2be8d1b44bb6e98c3 (patch) | |
tree | 956d758c3aed8d550b3410883453f5ecfa051d68 | |
parent | ac4b4b7f02cff3a3e77292da89d0eb3c7deca34e (diff) | |
download | jdk8u-0817dd2ef1a71f42b9ed5cb2be8d1b44bb6e98c3.tar.gz |
8210416: [linux] Poor StrictMath performance due to non-optimized compilation
Summary: Compile fdlibm with -O3 and relevant C flags on gcc arches.
Reviewed-by: mbaesken, andrew
-rw-r--r-- | common/autoconf/flags.m4 | 33 | ||||
-rw-r--r-- | common/autoconf/generated-configure.sh | 149 | ||||
-rw-r--r-- | common/autoconf/spec.gmk.in | 1 |
3 files changed, 181 insertions, 2 deletions
diff --git a/common/autoconf/flags.m4 b/common/autoconf/flags.m4 index 9c73e42..20ad5e9 100644 --- a/common/autoconf/flags.m4 +++ b/common/autoconf/flags.m4 @@ -455,6 +455,7 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK], # Later we will also have CFLAGS and LDFLAGS for the hotspot subrepo build. # + FDLIBM_CFLAGS="" # Setup compiler/platform specific flags to CFLAGS_JDK, # CXXFLAGS_JDK and CCXXFLAGS_JDK (common to C and CXX?) if test "x$TOOLCHAIN_TYPE" = xgcc; then @@ -479,6 +480,37 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK], ;; esac TOOLCHAIN_CHECK_COMPILER_VERSION(6, FLAGS_SETUP_GCC6_COMPILER_FLAGS) + + # Check that the compiler supports -ffp-contract=off flag + # Set FDLIBM_CFLAGS to -ffp-contract=off if it does. + # For GCC < 4.6, on x86, x86_64 and ppc check for + # -mno-fused-madd and -fno-strict-aliasing. If they exist, + # use them as a substitute for -ffp-contract=off. + # + # These flags are required for GCC-based builds of + # fdlibm with optimization without losing precision. + # Notably, -ffp-contract=off needs to be added for GCC >= 4.6, + # -mno-fused-madd -fno-strict-aliasing for GCC < 4.6 + COMPILER_FP_CONTRACT_OFF_FLAG="-ffp-contract=off" + FLAGS_CXX_COMPILER_CHECK_ARGUMENTS([[$]COMPILER_FP_CONTRACT_OFF_FLAG -Werror], + [], [COMPILER_FP_CONTRACT_OFF_FLAG=""]) + if test "x$COMPILER_FP_CONTRACT_OFF_FLAG" = x; then + if test "$OPENJDK_TARGET_CPU_ARCH" = "x86" || + test "$OPENJDK_TARGET_CPU_ARCH" = "x86_64" || + test "$OPENJDK_TARGET_CPU_ARCH" = "ppc"; then + M_NO_FUSED_ADD_FLAG="-mno-fused-madd" + FLAGS_CXX_COMPILER_CHECK_ARGUMENTS([[$]M_NO_FUSED_ADD_FLAG -Werror], + [], [M_NO_FUSED_ADD_FLAG=""]) + NO_STRICT_ALIASING_FLAG="-fno-strict-aliasing" + FLAGS_CXX_COMPILER_CHECK_ARGUMENTS([[$]NO_STRICT_ALIASING_FLAG -Werror], + [], [NO_STRICT_ALIASING_FLAG=""]) + if test "x$M_NO_FUSED_ADD_FLAG" != "x" && test "x$NO_STRICT_ALIASING_FLAG" != "x"; then + FDLIBM_CFLAGS="$M_NO_FUSED_ADD_FLAG $NO_STRICT_ALIASING_FLAG" + fi + fi + else + FDLIBM_CFLAGS="$COMPILER_FP_CONTRACT_OFF_FLAG" + fi elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS" if test "x$OPENJDK_TARGET_CPU_ARCH" = xx86; then @@ -510,6 +542,7 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK], -D_STATIC_CPPLIB -D_DISABLE_DEPRECATE_STATIC_CPPLIB" fi fi + AC_SUBST(FDLIBM_CFLAGS) ############################################################################### diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index af4dbcc..560f049 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -686,6 +686,7 @@ CXXFLAGS_JDKLIB CFLAGS_JDKEXE CFLAGS_JDKLIB MACOSX_VERSION_MIN +FDLIBM_CFLAGS NO_LIFETIME_DSE_CFLAG NO_DELETE_NULL_POINTER_CHECKS_CFLAG LEGACY_EXTRA_LDFLAGS @@ -3908,7 +3909,7 @@ pkgadd_help() { # -# Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -4375,7 +4376,7 @@ VS_SDK_PLATFORM_NAME_2017= #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1553405262 +DATE_WHEN_GENERATED=1556533111 ############################################################################### # @@ -41550,6 +41551,7 @@ fi # Later we will also have CFLAGS and LDFLAGS for the hotspot subrepo build. # + FDLIBM_CFLAGS="" # Setup compiler/platform specific flags to CFLAGS_JDK, # CXXFLAGS_JDK and CCXXFLAGS_JDK (common to C and CXX?) if test "x$TOOLCHAIN_TYPE" = xgcc; then @@ -41791,6 +41793,148 @@ $as_echo "$supports" >&6; } : fi + + # Check that the compiler supports -ffp-contract=off flag + # Set FDLIBM_CFLAGS to -ffp-contract=off if it does. + # For GCC < 4.6, on x86, x86_64 and ppc check for + # -mno-fused-madd and -fno-strict-aliasing. If they exist, + # use them as a substitute for -ffp-contract=off. + # + # These flags are required for GCC-based builds of + # fdlibm with optimization without losing precision. + # Notably, -ffp-contract=off needs to be added for GCC >= 4.6, + # -mno-fused-madd -fno-strict-aliasing for GCC < 4.6 + COMPILER_FP_CONTRACT_OFF_FLAG="-ffp-contract=off" + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the C++ compiler supports \"$COMPILER_FP_CONTRACT_OFF_FLAG -Werror\"" >&5 +$as_echo_n "checking if the C++ compiler supports \"$COMPILER_FP_CONTRACT_OFF_FLAG -Werror\"... " >&6; } + supports=yes + + saved_cxxflags="$CXXFLAGS" + CXXFLAGS="$CXXFLAG $COMPILER_FP_CONTRACT_OFF_FLAG -Werror" + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +int i; +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + +else + supports=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + CXXFLAGS="$saved_cxxflags" + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $supports" >&5 +$as_echo "$supports" >&6; } + if test "x$supports" = "xyes" ; then + : + else + COMPILER_FP_CONTRACT_OFF_FLAG="" + fi + + if test "x$COMPILER_FP_CONTRACT_OFF_FLAG" = x; then + if test "$OPENJDK_TARGET_CPU_ARCH" = "x86" || + test "$OPENJDK_TARGET_CPU_ARCH" = "x86_64" || + test "$OPENJDK_TARGET_CPU_ARCH" = "ppc"; then + M_NO_FUSED_ADD_FLAG="-mno-fused-madd" + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the C++ compiler supports \"$M_NO_FUSED_ADD_FLAG -Werror\"" >&5 +$as_echo_n "checking if the C++ compiler supports \"$M_NO_FUSED_ADD_FLAG -Werror\"... " >&6; } + supports=yes + + saved_cxxflags="$CXXFLAGS" + CXXFLAGS="$CXXFLAG $M_NO_FUSED_ADD_FLAG -Werror" + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +int i; +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + +else + supports=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + CXXFLAGS="$saved_cxxflags" + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $supports" >&5 +$as_echo "$supports" >&6; } + if test "x$supports" = "xyes" ; then + : + else + M_NO_FUSED_ADD_FLAG="" + fi + + NO_STRICT_ALIASING_FLAG="-fno-strict-aliasing" + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the C++ compiler supports \"$NO_STRICT_ALIASING_FLAG -Werror\"" >&5 +$as_echo_n "checking if the C++ compiler supports \"$NO_STRICT_ALIASING_FLAG -Werror\"... " >&6; } + supports=yes + + saved_cxxflags="$CXXFLAGS" + CXXFLAGS="$CXXFLAG $NO_STRICT_ALIASING_FLAG -Werror" + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +int i; +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + +else + supports=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + CXXFLAGS="$saved_cxxflags" + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $supports" >&5 +$as_echo "$supports" >&6; } + if test "x$supports" = "xyes" ; then + : + else + NO_STRICT_ALIASING_FLAG="" + fi + + if test "x$M_NO_FUSED_ADD_FLAG" != "x" && test "x$NO_STRICT_ALIASING_FLAG" != "x"; then + FDLIBM_CFLAGS="$M_NO_FUSED_ADD_FLAG $NO_STRICT_ALIASING_FLAG" + fi + fi + else + FDLIBM_CFLAGS="$COMPILER_FP_CONTRACT_OFF_FLAG" + fi elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS" if test "x$OPENJDK_TARGET_CPU_ARCH" = xx86; then @@ -41823,6 +41967,7 @@ $as_echo "$supports" >&6; } fi fi + ############################################################################### # Adjust flags according to debug level. diff --git a/common/autoconf/spec.gmk.in b/common/autoconf/spec.gmk.in index 0ffdacd..88f9f53 100644 --- a/common/autoconf/spec.gmk.in +++ b/common/autoconf/spec.gmk.in @@ -356,6 +356,7 @@ CXX_FLAG_DEPS:=@CXX_FLAG_DEPS@ CC:=@FIXPATH@ @CCACHE@ @CC@ # CFLAGS used to compile the jdk native libraries (C-code) +FDLIBM_CFLAGS:=@FDLIBM_CFLAGS@ CFLAGS_JDKLIB:=@CFLAGS_JDKLIB@ CXXFLAGS_JDKLIB:=@CXXFLAGS_JDKLIB@ |