Patchwork PR tree-optimization/44687 (partial inlining and nrv at i386)

login
register
mail settings
Submitter Jan Hubicka
Date June 28, 2010, 12:37 p.m.
Message ID <20100628123705.GA6233@kam.mff.cuni.cz>
Download mbox | patch
Permalink /patch/57135/
State New
Headers show

Comments

Jan Hubicka - June 28, 2010, 12:37 p.m.
Hi,
the problem here is that ipa-split when building new return statement it use ordinary var
to pass return value where RESULT_DECL is expected.
Fixed thus.  It might be nice to extend statement verifier to check this, but I am not
sure when exactly we insist on RESULT_DECL and when not. (for aggregates or in more complex
scenarios?)

Bootstrapped/regtested x86_64-linux, OK?
Honza

typedef int int32_t;                                                                                                                                                   
typedef unsigned char uint8_t;                                                                                                                                         
struct S0                                                                                                                                                              
{                                                                                                                                                                      
  uint8_t f0;                                                                                                                                                          
};                                                                                                                                                                     
struct S0 *g_18[7][5][1][1] = {                                                                                                                                        
};                                                                                                                                                                     
                                                                                                                                                                       
struct S0 **g_17 = &g_18[0][3][0][0];                                                                                                                                  
int32_t g_86;                                                                                                                                                          
struct S0 func_72 (uint8_t p_73, struct S0 p_74);                                                                                                                      
                                                                                                                                                                       
void int326 (struct S0 **p_67, int32_t p_68, int32_t * *const p_69,                                                                                                    
        struct S0 *p_70)                                                                                                                                               
{                                                                                                                                                                      
  struct S0 l_95 = {                                                                                                                                                   
    -1L                                                                                                                                                                
  };                                                                                                                                                                   
  func_72 (1L, func_72 (0, l_95));                                                                                                                                     
}                                                                                                                                                                      
                                                                                                                                                                       
struct S0                                                                                                                                                              
func_72 (uint8_t p_73, struct S0 p_74)                                                                                                                                 
{                                                                                                                                                                      
  int32_t *l_85 = &g_86;                                                                                                                                               
  if (*l_85)                                                                                                                                                           
  lbl_94:*l_85 ^= 0;                                                                                                                                                   
  if (g_86)                                                                                                                                                            
    goto lbl_94;                                                                                                                                                       
  return **g_17;                                                                                                                                                       
}   
	PR tree-optimization/44687
	* ipa-split.c (split_function): Use DECL_RESULT to store return value.
Richard Guenther - June 28, 2010, 12:42 p.m.
On Mon, Jun 28, 2010 at 2:37 PM, Jan Hubicka <hubicka@ucw.cz> wrote:
> Hi,
> the problem here is that ipa-split when building new return statement it use ordinary var
> to pass return value where RESULT_DECL is expected.
> Fixed thus.  It might be nice to extend statement verifier to check this, but I am not
> sure when exactly we insist on RESULT_DECL and when not. (for aggregates or in more complex
> scenarios?)

We always insist in DECL_RESULT being used (if it exists, which
it probably always does if your testing succeeded).

>
> Bootstrapped/regtested x86_64-linux, OK?

Please add the testcase.

Ok.

THanks,
Ricahrd.

> Honza
>
> typedef int int32_t;
> typedef unsigned char uint8_t;
> struct S0
> {
>  uint8_t f0;
> };
> struct S0 *g_18[7][5][1][1] = {
> };
>
> struct S0 **g_17 = &g_18[0][3][0][0];
> int32_t g_86;
> struct S0 func_72 (uint8_t p_73, struct S0 p_74);
>
> void int326 (struct S0 **p_67, int32_t p_68, int32_t * *const p_69,
>        struct S0 *p_70)
> {
>  struct S0 l_95 = {
>    -1L
>  };
>  func_72 (1L, func_72 (0, l_95));
> }
>
> struct S0
> func_72 (uint8_t p_73, struct S0 p_74)
> {
>  int32_t *l_85 = &g_86;
>  if (*l_85)
>  lbl_94:*l_85 ^= 0;
>  if (g_86)
>    goto lbl_94;
>  return **g_17;
> }
>        PR tree-optimization/44687
>        * ipa-split.c (split_function): Use DECL_RESULT to store return value.
> Index: ipa-split.c
> ===================================================================
> --- ipa-split.c (revision 161476)
> +++ ipa-split.c (working copy)
> @@ -928,9 +928,7 @@ split_function (struct split_point *spli
>          gimple ret;
>          if (!VOID_TYPE_P (TREE_TYPE (TREE_TYPE (current_function_decl))))
>            {
> -             retval
> -               = create_tmp_var (TREE_TYPE (TREE_TYPE (current_function_decl)),
> -                                 "RET");
> +             retval = DECL_RESULT (current_function_decl);
>              if (is_gimple_reg (retval))
>                retval = make_ssa_name (retval, call);
>              gimple_call_set_lhs (call, retval);
>
H.J. Lu - June 29, 2010, 4:45 a.m.
On Mon, Jun 28, 2010 at 5:37 AM, Jan Hubicka <hubicka@ucw.cz> wrote:
> Hi,
> the problem here is that ipa-split when building new return statement it use ordinary var
> to pass return value where RESULT_DECL is expected.
> Fixed thus.  It might be nice to extend statement verifier to check this, but I am not
> sure when exactly we insist on RESULT_DECL and when not. (for aggregates or in more complex
> scenarios?)
>
> Bootstrapped/regtested x86_64-linux, OK?
> Honza
>
> typedef int int32_t;
> typedef unsigned char uint8_t;
> struct S0
> {
>  uint8_t f0;
> };
> struct S0 *g_18[7][5][1][1] = {
> };
>
> struct S0 **g_17 = &g_18[0][3][0][0];
> int32_t g_86;
> struct S0 func_72 (uint8_t p_73, struct S0 p_74);
>
> void int326 (struct S0 **p_67, int32_t p_68, int32_t * *const p_69,
>        struct S0 *p_70)
> {
>  struct S0 l_95 = {
>    -1L
>  };
>  func_72 (1L, func_72 (0, l_95));
> }
>
> struct S0
> func_72 (uint8_t p_73, struct S0 p_74)
> {
>  int32_t *l_85 = &g_86;
>  if (*l_85)
>  lbl_94:*l_85 ^= 0;
>  if (g_86)
>    goto lbl_94;
>  return **g_17;
> }
>        PR tree-optimization/44687
>        * ipa-split.c (split_function): Use DECL_RESULT to store return value.

This caused:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44706

Patch

Index: ipa-split.c
===================================================================
--- ipa-split.c	(revision 161476)
+++ ipa-split.c	(working copy)
@@ -928,9 +928,7 @@  split_function (struct split_point *spli
 	  gimple ret;
 	  if (!VOID_TYPE_P (TREE_TYPE (TREE_TYPE (current_function_decl))))
 	    {
-	      retval
-	        = create_tmp_var (TREE_TYPE (TREE_TYPE (current_function_decl)),
-				  "RET");
+	      retval = DECL_RESULT (current_function_decl);
 	      if (is_gimple_reg (retval))
 		retval = make_ssa_name (retval, call);
 	      gimple_call_set_lhs (call, retval);