[PATCH] Improve error on invalid call to __builtin_cexpi (PR31161)

Richard Guenther rguenther@suse.de
Thu Mar 15 14:30:00 GMT 2007


On Thu, 15 Mar 2007, Richard Guenther wrote:

> On Wed, 14 Mar 2007, Andrew Pinski wrote:
> 
> > On 3/14/07, Richard Guenther <rguenther@suse.de> wrote:
> > >
> > > 2007-03-12  Richard Guenther  <rguenther@suse.de>
> > >
> > >         PR middle-end/31161
> > >         * builtins.c (expand_builtin_cexpi): Bail out more friendly
> > >         if we cannot expand a call to __builtin_cexpi.
> > 
> > Why not just emit a call to __builtin_cexpi instead like how the
> > __sync_* functions do?
> 
> I've ended up with the following, falling back to cexp and its variants.
> This should result in the best possible user-experience if the user
> calls __builtin_cepxi.

Likewise here's a variant for PR29719 which ICEs on __builtin_lfloorf
on non-C99 targets.  Verified it now works with a cross to ppc-darwin.

Bootstrap and regtest in progress (the one for the other patch now 
completed successfully).

Looks like a new helper function would make name construction prettier...

Richard.


2007-03-15  Richard Guenther  <rguenther@suse.de>

	PR middle-end/29719
	* builtins.c (expand_builtin_int_roundingfn): Always fall
	back to floor/ceil and its variants even if they may be
	not available.

Index: builtins.c
===================================================================
*** builtins.c	(revision 122953)
--- builtins.c	(working copy)
*************** expand_builtin_int_roundingfn (tree exp,
*** 2480,2488 ****
  
    /* Fall back to floating point rounding optab.  */
    fallback_fndecl = mathfn_built_in (TREE_TYPE (arg), fallback_fn);
!   /* We shouldn't get here on targets without TARGET_C99_FUNCTIONS.
!      ??? Perhaps convert (int)floorf(x) into (int)floor((double)x).  */
!   gcc_assert (fallback_fndecl != NULL_TREE);
    exp = build_call_expr (fallback_fndecl, 1, arg);
  
    tmp = expand_normal (exp);
--- 2497,2547 ----
  
    /* Fall back to floating point rounding optab.  */
    fallback_fndecl = mathfn_built_in (TREE_TYPE (arg), fallback_fn);
! 
!   /* For non-C99 targets we may end up without a fallback fndecl here
!      if the user called __builtin_lfloor directly.  In this case emit
!      a call to the floor/ceil variants nevertheless.  This should result
!      in the best user experience for not full C99 targets.  */
!   if (fallback_fndecl == NULL_TREE)
!     {
!       tree fntype;
!       const char *name = NULL;
! 
!       switch (DECL_FUNCTION_CODE (fndecl))
! 	{
! 	case BUILT_IN_LCEIL:
! 	case BUILT_IN_LLCEIL:
! 	  name = "ceil";
! 	  break;
! 	case BUILT_IN_LCEILF:
! 	case BUILT_IN_LLCEILF:
! 	  name = "ceilf";
! 	  break;
! 	case BUILT_IN_LCEILL:
! 	case BUILT_IN_LLCEILL:
! 	  name = "ceill";
! 	  break;
! 	case BUILT_IN_LFLOOR:
! 	case BUILT_IN_LLFLOOR:
! 	  name = "floor";
! 	  break;
! 	case BUILT_IN_LFLOORF:
! 	case BUILT_IN_LLFLOORF:
! 	  name = "floorf";
! 	  break;
! 	case BUILT_IN_LFLOORL:
! 	case BUILT_IN_LLFLOORL:
! 	  name = "floorl";
! 	  break;
! 	default:
! 	  gcc_unreachable ();
! 	}
! 
!       fntype = build_function_type_list (TREE_TYPE (arg),
! 					 TREE_TYPE (arg), NULL_TREE);
!       fallback_fndecl = build_fn_decl (name, fntype);
!     }
! 
    exp = build_call_expr (fallback_fndecl, 1, arg);
  
    tmp = expand_normal (exp);



More information about the Gcc-patches mailing list