This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH]: Fix PR 3120



This updates my previous patch "Resolve mainline builtin sqrt issues"
http://gcc.gnu.org/ml/gcc-patches/2001-11/msg01328.html so that it
applies cleanly to current mainline sources.  It fixes high priority
PR c/3120 which is a regression from the 3.0 branch.

I've retested this updated patch with "make bootstrap" and "make -k
check" on i686-pc-linux-gnu with no new regressions.  Its been approved
by Gabriel Dos Reis in a private e-mail.  Andreas, could you please
apply this patch and close the PR?


2001-12-13  Roger Sayle <roger@eyesopen.com>
	* builtins.def: Rename BUILT_IN_FSQRT to BUILT_IN_SQRT and
	__builtin_fsqrt to __builtin_sqrt.
	* builtins.c (expand_builtin_mathfn,expand_builtin): Same.
	* doc/extend.texi: Simplify documentation to match patch.

	* f/com-rt.def: Use __builtin_sqrt instead of __builtin_fsqrt.
	* f/com.c (ffecom_init_0): Same, and fixed enumeration usage.

	* libstdc++-v3/acconfig.h: Test for __builtin_sqrt instead of
	__builtin_fsqrt.
	* libstdc++-v3/acinclude.m4: Same.
	* libstdc++-v3/include/c_shadow/bits/std_cmath.h: Same.


diff -c3pr gcc/gcc/builtins.c patch1/gcc/builtins.c
*** gcc/gcc/builtins.c	Thu Dec 13 12:10:51 2001
--- patch1/gcc/builtins.c	Thu Dec 13 17:53:00 2001
*************** expand_builtin_mathfn (exp, target, subt
*** 1506,1512 ****
      case BUILT_IN_COSF:
      case BUILT_IN_COSL:
        builtin_optab = cos_optab; break;
!     case BUILT_IN_FSQRT:
      case BUILT_IN_SQRTF:
      case BUILT_IN_SQRTL:
        builtin_optab = sqrt_optab; break;
--- 1506,1512 ----
      case BUILT_IN_COSF:
      case BUILT_IN_COSL:
        builtin_optab = cos_optab; break;
!     case BUILT_IN_SQRT:
      case BUILT_IN_SQRTF:
      case BUILT_IN_SQRTL:
        builtin_optab = sqrt_optab; break;
*************** expand_builtin (exp, target, subtarget,
*** 3550,3556 ****
        {
        case BUILT_IN_SIN:
        case BUILT_IN_COS:
!       case BUILT_IN_FSQRT:
        case BUILT_IN_SQRTF:
        case BUILT_IN_SQRTL:
        case BUILT_IN_MEMSET:
--- 3550,3556 ----
        {
        case BUILT_IN_SIN:
        case BUILT_IN_COS:
!       case BUILT_IN_SQRT:
        case BUILT_IN_SQRTF:
        case BUILT_IN_SQRTL:
        case BUILT_IN_MEMSET:
*************** expand_builtin (exp, target, subtarget,
*** 3621,3627 ****
  	 because of possible accuracy problems.  */
        if (! flag_unsafe_math_optimizations)
  	break;
!     case BUILT_IN_FSQRT:
      case BUILT_IN_SQRTF:
      case BUILT_IN_SQRTL:
        target = expand_builtin_mathfn (exp, target, subtarget);
--- 3621,3627 ----
  	 because of possible accuracy problems.  */
        if (! flag_unsafe_math_optimizations)
  	break;
!     case BUILT_IN_SQRT:
      case BUILT_IN_SQRTF:
      case BUILT_IN_SQRTL:
        target = expand_builtin_mathfn (exp, target, subtarget);
diff -c3pr gcc/gcc/builtins.def patch1/gcc/builtins.def
*** gcc/gcc/builtins.def	Sun Dec  9 11:26:56 2001
--- patch1/gcc/builtins.def	Thu Dec 13 17:53:47 2001
*************** DEF_LIB_BUILTIN(BUILT_IN_STRRCHR,
*** 263,270 ****
  		"__builtin_strrchr",
  		BT_FN_STRING_CONST_STRING_INT)

! DEF_LIB_BUILTIN(BUILT_IN_FSQRT,
! 		"__builtin_fsqrt",
  		BT_FN_DOUBLE_DOUBLE)
  DEF_LIB_BUILTIN(BUILT_IN_SIN,
  		"__builtin_sin",
--- 263,270 ----
  		"__builtin_strrchr",
  		BT_FN_STRING_CONST_STRING_INT)

! DEF_LIB_BUILTIN(BUILT_IN_SQRT,
! 		"__builtin_sqrt",
  		BT_FN_DOUBLE_DOUBLE)
  DEF_LIB_BUILTIN(BUILT_IN_SIN,
  		"__builtin_sin",
diff -c3pr gcc/gcc/doc/extend.texi patch1/gcc/doc/extend.texi
*** gcc/gcc/doc/extend.texi	Thu Dec 13 12:11:08 2001
--- patch1/gcc/doc/extend.texi	Thu Dec 13 17:54:12 2001
*************** The ISO C89 functions @code{abs}, @code{
*** 4400,4409 ****
  @code{strpbrk}, @code{strrchr}, @code{strspn}, and @code{strstr} are all
  recognized as built-in functions unless @option{-fno-builtin} is
  specified (or @option{-fno-builtin-@var{function}} is specified for an
! individual function).  All of these functions have
! corresponding versions prefixed
! with @code{__builtin_}, except that the version for @code{sqrt} is
! called @code{__builtin_fsqrt}.

  GCC provides built-in versions of the ISO C99 floating point comparison
  macros that avoid raising exceptions for unordered operands.  They have
--- 4400,4407 ----
  @code{strpbrk}, @code{strrchr}, @code{strspn}, and @code{strstr} are all
  recognized as built-in functions unless @option{-fno-builtin} is
  specified (or @option{-fno-builtin-@var{function}} is specified for an
! individual function).  All of these functions have corresponding
! versions prefixed with @code{__builtin_}.

  GCC provides built-in versions of the ISO C99 floating point comparison
  macros that avoid raising exceptions for unordered operands.  They have
diff -c3pr gcc/gcc/f/com-rt.def patch1/gcc/f/com-rt.def
*** gcc/gcc/f/com-rt.def	Wed Aug 23 15:16:19 2000
--- patch1/gcc/f/com-rt.def	Thu Dec 13 17:55:59 2001
*************** DEFGFRT (FFECOM_gfrtL_LOG10, "log10", FF
*** 273,279 ****
  DEFGFRT (FFECOM_gfrtL_POW, "pow", FFECOM_rttypeDOUBLE_, "d", FALSE, FALSE, TRUE)
  DEFGFRT (FFECOM_gfrtL_SIN, "__builtin_sin", FFECOM_rttypeDOUBLE_, "d", FALSE, FALSE, TRUE)
  DEFGFRT (FFECOM_gfrtL_SINH, "sinh", FFECOM_rttypeDOUBLE_, "d", FALSE, FALSE, TRUE)
! DEFGFRT (FFECOM_gfrtL_SQRT, "__builtin_fsqrt", FFECOM_rttypeDOUBLE_, "d", FALSE, FALSE, TRUE)
  DEFGFRT (FFECOM_gfrtL_TAN, "tan", FFECOM_rttypeDOUBLE_, "d", FALSE, FALSE, TRUE)
  DEFGFRT (FFECOM_gfrtL_TANH, "tanh", FFECOM_rttypeDOUBLE_, "d", FALSE, FALSE, TRUE)

--- 273,279 ----
  DEFGFRT (FFECOM_gfrtL_POW, "pow", FFECOM_rttypeDOUBLE_, "d", FALSE, FALSE, TRUE)
  DEFGFRT (FFECOM_gfrtL_SIN, "__builtin_sin", FFECOM_rttypeDOUBLE_, "d", FALSE, FALSE, TRUE)
  DEFGFRT (FFECOM_gfrtL_SINH, "sinh", FFECOM_rttypeDOUBLE_, "d", FALSE, FALSE, TRUE)
! DEFGFRT (FFECOM_gfrtL_SQRT, "__builtin_sqrt", FFECOM_rttypeDOUBLE_, "d", FALSE, FALSE, TRUE)
  DEFGFRT (FFECOM_gfrtL_TAN, "tan", FFECOM_rttypeDOUBLE_, "d", FALSE, FALSE, TRUE)
  DEFGFRT (FFECOM_gfrtL_TANH, "tanh", FFECOM_rttypeDOUBLE_, "d", FALSE, FALSE, TRUE)

diff -c3pr gcc/gcc/f/com.c patch1/gcc/f/com.c
*** gcc/gcc/f/com.c	Sun Dec  9 11:28:22 2001
--- patch1/gcc/f/com.c	Thu Dec 13 17:57:01 2001
*************** ffecom_init_0 ()
*** 11713,11735 ****
      = build_function_type (void_type_node, NULL_TREE);

    builtin_function ("__builtin_sqrtf", float_ftype_float,
! 		    BUILT_IN_FSQRT, BUILT_IN_NORMAL, "sqrtf");
!   builtin_function ("__builtin_fsqrt", double_ftype_double,
! 		    BUILT_IN_FSQRT, BUILT_IN_NORMAL, "sqrt");
    builtin_function ("__builtin_sqrtl", ldouble_ftype_ldouble,
! 		    BUILT_IN_FSQRT, BUILT_IN_NORMAL, "sqrtl");
    builtin_function ("__builtin_sinf", float_ftype_float,
! 		    BUILT_IN_SIN, BUILT_IN_NORMAL, "sinf");
    builtin_function ("__builtin_sin", double_ftype_double,
  		    BUILT_IN_SIN, BUILT_IN_NORMAL, "sin");
    builtin_function ("__builtin_sinl", ldouble_ftype_ldouble,
! 		    BUILT_IN_SIN, BUILT_IN_NORMAL, "sinl");
    builtin_function ("__builtin_cosf", float_ftype_float,
! 		    BUILT_IN_COS, BUILT_IN_NORMAL, "cosf");
    builtin_function ("__builtin_cos", double_ftype_double,
  		    BUILT_IN_COS, BUILT_IN_NORMAL, "cos");
    builtin_function ("__builtin_cosl", ldouble_ftype_ldouble,
! 		    BUILT_IN_COS, BUILT_IN_NORMAL, "cosl");

    pedantic_lvalues = FALSE;

--- 11713,11735 ----
      = build_function_type (void_type_node, NULL_TREE);

    builtin_function ("__builtin_sqrtf", float_ftype_float,
! 		    BUILT_IN_SQRTF, BUILT_IN_NORMAL, "sqrtf");
!   builtin_function ("__builtin_sqrt", double_ftype_double,
! 		    BUILT_IN_SQRT, BUILT_IN_NORMAL, "sqrt");
    builtin_function ("__builtin_sqrtl", ldouble_ftype_ldouble,
! 		    BUILT_IN_SQRTL, BUILT_IN_NORMAL, "sqrtl");
    builtin_function ("__builtin_sinf", float_ftype_float,
! 		    BUILT_IN_SINF, BUILT_IN_NORMAL, "sinf");
    builtin_function ("__builtin_sin", double_ftype_double,
  		    BUILT_IN_SIN, BUILT_IN_NORMAL, "sin");
    builtin_function ("__builtin_sinl", ldouble_ftype_ldouble,
! 		    BUILT_IN_SINL, BUILT_IN_NORMAL, "sinl");
    builtin_function ("__builtin_cosf", float_ftype_float,
! 		    BUILT_IN_COSF, BUILT_IN_NORMAL, "cosf");
    builtin_function ("__builtin_cos", double_ftype_double,
  		    BUILT_IN_COS, BUILT_IN_NORMAL, "cos");
    builtin_function ("__builtin_cosl", ldouble_ftype_ldouble,
! 		    BUILT_IN_COSL, BUILT_IN_NORMAL, "cosl");

    pedantic_lvalues = FALSE;

diff -c3pr gcc/libstdc++-v3/acconfig.h patch1/libstdc++-v3/acconfig.h
*** gcc/libstdc++-v3/acconfig.h	Fri Nov  2 15:30:57 2001
--- patch1/libstdc++-v3/acconfig.h	Thu Dec 13 17:58:01 2001
***************
*** 100,107 ****
  // Define if the compiler/host combination has __builtin_sinl
  #undef HAVE___BUILTIN_SINL

! // Define if the compiler/host combination has __builtin_fsqrt
! #undef HAVE___BUILTIN_FSQRT

  // Define if the compiler/host combination has __builtin_sqrtf
  #undef HAVE___BUILTIN_SQRTF
--- 100,107 ----
  // Define if the compiler/host combination has __builtin_sinl
  #undef HAVE___BUILTIN_SINL

! // Define if the compiler/host combination has __builtin_sqrt
! #undef HAVE___BUILTIN_SQRT

  // Define if the compiler/host combination has __builtin_sqrtf
  #undef HAVE___BUILTIN_SQRTF
diff -c3pr gcc/libstdc++-v3/acinclude.m4 patch1/libstdc++-v3/acinclude.m4
*** gcc/libstdc++-v3/acinclude.m4	Fri Nov 23 10:56:56 2001
--- patch1/libstdc++-v3/acinclude.m4	Thu Dec 13 17:59:06 2001
*************** dnl check for __builtin_fabl
*** 587,593 ****
  dnl check for __builtin_labs
  dnl check for __builtin_sqrtf
  dnl check for __builtin_sqrtl
! dnl check for __builtin_fsqrt
  dnl check for __builtin_sinf
  dnl check for __builtin_sin
  dnl check for __builtin_sinl
--- 587,593 ----
  dnl check for __builtin_labs
  dnl check for __builtin_sqrtf
  dnl check for __builtin_sqrtl
! dnl check for __builtin_sqrt
  dnl check for __builtin_sinf
  dnl check for __builtin_sin
  dnl check for __builtin_sinl
*************** AC_DEFUN(GLIBCPP_CHECK_BUILTIN_MATH_SUPP
*** 606,612 ****
    GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_labs)

    GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sqrtf)
!   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fsqrt)
    GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sqrtl)

    GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sinf)
--- 606,612 ----
    GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_labs)

    GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sqrtf)
!   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sqrt)
    GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sqrtl)

    GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sinf)
*************** AC_DEFUN(GLIBCPP_CHECK_BUILTIN_MATH_SUPP
*** 636,642 ****
      AC_DEFINE(HAVE___BUILTIN_SIN)
      AC_DEFINE(HAVE___BUILTIN_SINF)
      AC_DEFINE(HAVE___BUILTIN_SINL)
!     AC_DEFINE(HAVE___BUILTIN_FSQRT)
      AC_DEFINE(HAVE___BUILTIN_SQRTF)
      AC_DEFINE(HAVE___BUILTIN_SQRTL)
    fi
--- 636,642 ----
      AC_DEFINE(HAVE___BUILTIN_SIN)
      AC_DEFINE(HAVE___BUILTIN_SINF)
      AC_DEFINE(HAVE___BUILTIN_SINL)
!     AC_DEFINE(HAVE___BUILTIN_SQRT)
      AC_DEFINE(HAVE___BUILTIN_SQRTF)
      AC_DEFINE(HAVE___BUILTIN_SQRTL)
    fi
diff -c3pr gcc/libstdc++-v3/include/c_shadow/bits/std_cmath.h patch1/libstdc++-v3/include/c_shadow/bits/std_cmath.h
*** gcc/libstdc++-v3/include/c_shadow/bits/std_cmath.h	Thu Dec 21 15:46:26 2000
--- patch1/libstdc++-v3/include/c_shadow/bits/std_cmath.h	Thu Dec 13 18:00:08 2001
*************** namespace _C_legacy {
*** 318,324 ****

  #if _GLIBCPP_HAVE___BUILTIN_SQRT
    inline double
!   _CPP_sqrt_capture(double __x) { return __builtin_fsqrt(__x); }
  #else
    inline double
    _CPP_sqrt_capture(double __x) { return sqrt(__x); }
--- 318,324 ----

  #if _GLIBCPP_HAVE___BUILTIN_SQRT
    inline double
!   _CPP_sqrt_capture(double __x) { return __builtin_sqrt(__x); }
  #else
    inline double
    _CPP_sqrt_capture(double __x) { return sqrt(__x); }

Roger
--
Roger Sayle,                         E-mail: roger@eyesopen.com
OpenEye Scientific Software,         WWW: http://www.eyesopen.com/
Suite 1107, 3600 Cerrillos Road,     Tel: (+1) 505-473-7385
Santa Fe, New Mexico, 87507.         Fax: (+1) 505-438-3470



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]