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]

[Committed] Fix ICE compiling builtins-57.c on darwin


As reported by Andrew Pinski on IRC, the recent optimization to
transform floor of non-negative arguments into trunc fails to
check that it's on a TARGET_C99_FUNCTIONS platform.  This manifests
itself as mathfn_built_in returning NULL_TREE for BUILT_IN_TRUNC.
This should be fixed by the obvious patch below.

The following patch has been tested with a full "make bootstrap",
on x86_64-unknown-linux-gnu, all default languages.

Committed to mainline as revision 118168.



2006-10-29  Roger Sayle  <roger@eyesopen.com>

	* builtins.c (fold_builtin_floor): Check for the availability of
	the C99 trunc function before transforming floor into trunc.


Index: builtins.c
===================================================================
*** builtins.c	(revision 118098)
--- builtins.c	(working copy)
*************** fold_builtin_floor (tree fndecl, tree ar
*** 7308,7316 ****

    /* Fold floor (x) where x is nonnegative to trunc (x).  */
    if (tree_expr_nonnegative_p (arg))
!     return build_function_call_expr (mathfn_built_in (TREE_TYPE (arg),
! 						      BUILT_IN_TRUNC),
! 				     arglist);

    return fold_trunc_transparent_mathfn (fndecl, arglist);
  }
--- 7308,7318 ----

    /* Fold floor (x) where x is nonnegative to trunc (x).  */
    if (tree_expr_nonnegative_p (arg))
!     {
!       tree truncfn = mathfn_built_in (TREE_TYPE (arg), BUILT_IN_TRUNC);
!       if (truncfn)
! 	return build_function_call_expr (truncfn, arglist);
!     }

    return fold_trunc_transparent_mathfn (fndecl, arglist);
  }


Roger
--


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