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]: Reformat convert.c:convert_to_real() builtins


This patch reformats the builtins conditional in
convert.c:convert_to_real().  The purpose is to use a more compact and
readable representation less prone to typos in preparation for adding
more builtins.  This patch is just the reformatting, it doesn't change
any functionality yet.

Bootstrapped on sparc-sun-solaris2.7, no regressions.

Ok for mainline?

		Thanks,
		--Kaveh


2004-03-18  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* convert.c (convert_to_real): Reformat using switch stmt.

diff -rcp orig/egcc-CVS20040317/gcc/convert.c egcc-CVS20040317/gcc/convert.c
*** orig/egcc-CVS20040317/gcc/convert.c	Tue Mar 16 23:43:59 2004
--- egcc-CVS20040317/gcc/convert.c	Wed Mar 17 17:52:53 2004
*************** convert_to_real (tree type, tree expr)
*** 131,174 ****
       present in runtime.  */
    /* Convert (float)sqrt((double)x) where x is float into sqrtf(x) */
    if (optimize
-       && (fcode == BUILT_IN_SQRT
- 	  || fcode == BUILT_IN_SQRTL
- 	  || fcode == BUILT_IN_SIN
- 	  || fcode == BUILT_IN_SINL
- 	  || fcode == BUILT_IN_COS
- 	  || fcode == BUILT_IN_COSL
- 	  || fcode == BUILT_IN_EXP
- 	  || fcode == BUILT_IN_EXPL
- 	  || fcode == BUILT_IN_LOG
- 	  || fcode == BUILT_IN_LOGL)
        && (TYPE_MODE (type) == TYPE_MODE (double_type_node)
            || TYPE_MODE (type) == TYPE_MODE (float_type_node)))
      {
!       tree arg0 = strip_float_extensions (TREE_VALUE (TREE_OPERAND (expr, 1)));
!       tree newtype = type;
  
!       /* We have (outertype)sqrt((innertype)x).  Choose the wider mode from
! 	 the both as the safe type for operation.  */
!       if (TYPE_PRECISION (TREE_TYPE (arg0)) > TYPE_PRECISION (type))
! 	newtype = TREE_TYPE (arg0);
! 
!       /* Be careful about integer to fp conversions.
! 	 These may overflow still.  */
!       if (FLOAT_TYPE_P (TREE_TYPE (arg0))
! 	  && TYPE_PRECISION (newtype) < TYPE_PRECISION (itype)
! 	  && (TYPE_MODE (newtype) == TYPE_MODE (double_type_node)
! 	      || TYPE_MODE (newtype) == TYPE_MODE (float_type_node)))
! 	{
! 	  tree arglist;
! 	  tree fn = mathfn_built_in (newtype, fcode);
  
! 	  if (fn)
! 	    {
! 	      arglist = build_tree_list (NULL_TREE, fold (convert_to_real (newtype, arg0)));
! 	      expr = build_function_call_expr (fn, arglist);
! 	      if (newtype == type)
! 		return expr;
  	    }
  	}
      }
    if (optimize
--- 131,178 ----
       present in runtime.  */
    /* Convert (float)sqrt((double)x) where x is float into sqrtf(x) */
    if (optimize
        && (TYPE_MODE (type) == TYPE_MODE (double_type_node)
            || TYPE_MODE (type) == TYPE_MODE (float_type_node)))
      {
!       switch (fcode)
!         {
! #define CASE_MATHFN(FN) case BUILT_IN_##FN: case BUILT_IN_##FN##L:
! 	  CASE_MATHFN (SQRT)
! 	  CASE_MATHFN (SIN)
! 	  CASE_MATHFN (COS)
! 	  CASE_MATHFN (EXP)
! 	  CASE_MATHFN (LOG)
! #undef CASE_MATHFN
! 	    {
! 	      tree arg0 = strip_float_extensions (TREE_VALUE (TREE_OPERAND (expr, 1)));
! 	      tree newtype = type;
  
! 	      /* We have (outertype)sqrt((innertype)x).  Choose the wider mode from
! 		 the both as the safe type for operation.  */
! 	      if (TYPE_PRECISION (TREE_TYPE (arg0)) > TYPE_PRECISION (type))
! 		newtype = TREE_TYPE (arg0);
! 
! 	      /* Be careful about integer to fp conversions.
! 		 These may overflow still.  */
! 	      if (FLOAT_TYPE_P (TREE_TYPE (arg0))
! 		  && TYPE_PRECISION (newtype) < TYPE_PRECISION (itype)
! 		  && (TYPE_MODE (newtype) == TYPE_MODE (double_type_node)
! 		      || TYPE_MODE (newtype) == TYPE_MODE (float_type_node)))
! 	        {
! 		  tree arglist;
! 		  tree fn = mathfn_built_in (newtype, fcode);
  
! 		  if (fn)
! 		  {
! 		    arglist = build_tree_list (NULL_TREE, fold (convert_to_real (newtype, arg0)));
! 		    expr = build_function_call_expr (fn, arglist);
! 		    if (newtype == type)
! 		      return expr;
! 		  }
! 		}
  	    }
+ 	default:
+ 	  break;
  	}
      }
    if (optimize


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