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][C/C++] Do not promote return arguments


This patch disables promoting return arguments at the tree level and
leaves it to the expansion code.  This results in slightly smaller IL,
especially with inlining and boolean return types.

Bootstrapped and tested on x86_64-unknown-linux-gnu.

Ok for mainline?

Thanks,
Richard.

2007-07-05  Richard Guenther  <rguenther@suse.de>

	cp/
	* decl.c (start_preparsed_function): Do not promote return type.

	* c-decl.c (start_function): Do not promote return type.

Index: cp/decl.c
===================================================================
*** cp/decl.c	(revision 126357)
--- cp/decl.c	(working copy)
*************** start_preparsed_function (tree decl1, tr
*** 10844,10852 ****
  
    /* Build the return declaration for the function.  */
    restype = TREE_TYPE (fntype);
-   /* Promote the value to int before returning it.  */
-   if (c_promoting_integer_type_p (restype))
-     restype = type_promotes_to (restype);
    if (DECL_RESULT (decl1) == NULL_TREE)
      {
        tree resdecl;
--- 10844,10849 ----
Index: c-decl.c
===================================================================
*** c-decl.c	(revision 126357)
--- c-decl.c	(working copy)
*************** start_function (struct c_declspecs *decl
*** 6270,6287 ****
    declare_parm_level ();
  
    restype = TREE_TYPE (TREE_TYPE (current_function_decl));
-   /* Promote the value to int before returning it.  */
-   if (c_promoting_integer_type_p (restype))
-     {
-       /* It retains unsignedness if not really getting wider.  */
-       if (TYPE_UNSIGNED (restype)
- 	  && (TYPE_PRECISION (restype)
- 		  == TYPE_PRECISION (integer_type_node)))
- 	restype = unsigned_type_node;
-       else
- 	restype = integer_type_node;
-     }
- 
    resdecl = build_decl (RESULT_DECL, NULL_TREE, restype);
    DECL_ARTIFICIAL (resdecl) = 1;
    DECL_IGNORED_P (resdecl) = 1;
--- 6270,6275 ----


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