diff mbox

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

Message ID 20100628123705.GA6233@kam.mff.cuni.cz
State New
Headers show

Commit Message

Jan Hubicka June 28, 2010, 12:37 p.m. UTC
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.

Comments

Richard Biener June 28, 2010, 12:42 p.m. UTC | #1
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. UTC | #2
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
diff mbox

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);