提交 43b1095b 编写于 作者: S sgehwolf

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
上级 f2c011ba
......@@ -450,6 +450,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
......@@ -474,6 +475,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
......@@ -505,6 +537,7 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK],
-D_STATIC_CPPLIB -D_DISABLE_DEPRECATE_STATIC_CPPLIB"
fi
fi
AC_SUBST(FDLIBM_CFLAGS)
###############################################################################
......
......@@ -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
###############################################################################
#
......@@ -41545,6 +41546,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
......@@ -41786,6 +41788,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
......@@ -41818,6 +41962,7 @@ $as_echo "$supports" >&6; }
fi
fi
###############################################################################
# Adjust flags according to debug level.
......@@ -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@
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册