diff mbox

Use ECF_MAY_BE_ALLOCA for __builtin_alloca_with_align (PR tree-optimization/68680)

Message ID 20151204104715.GL5675@tucnak.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek Dec. 4, 2015, 10:47 a.m. UTC
On Fri, Dec 04, 2015 at 10:30:38AM +0100, Richard Biener wrote:
> > The following patch has been bootstrapped/regtested on x86_64-linux and
> > i686-linux.
> 
> The patch is ok - it looks like you could have removed the
> __builtin_alloca strcmp with it though.

Ok, will remove the strcmp then.

> Does the patch mean we inlined __builtin_alloca_with_align ()
> functions?  We might run into the issue Eric fixed lately with

Yes, see testcase below.  4.7+ inlines it.  As for tail call optimization,
seems we are just lucky there (f4), as fab pass which is quite late
turns the __builtin_stack_restore into GIMPLE_NOP and tailc pass does not
ignore nops.  Shall I commit following patch to trunk to fix that up
(after committing this VLA fix of course)?

int f1 (char *);

static inline void
f2 (int x)
{
  char a[x];
  f1 (a);
}

void
f3 (int x)
{
  f2 (x);
  f2 (x);
  f2 (x);
  f2 (x);
}

int
f4 (int x)
{
  char a[x];
  return f1 (a);
}

2015-12-04  Jakub Jelinek  <jakub@redhat.com>

	* tree-tailcall.c (find_tail_calls): Ignore GIMPLE_NOPs.



	Jakub

Comments

Richard Biener Dec. 4, 2015, 11 a.m. UTC | #1
On Fri, 4 Dec 2015, Jakub Jelinek wrote:

> On Fri, Dec 04, 2015 at 10:30:38AM +0100, Richard Biener wrote:
> > > The following patch has been bootstrapped/regtested on x86_64-linux and
> > > i686-linux.
> > 
> > The patch is ok - it looks like you could have removed the
> > __builtin_alloca strcmp with it though.
> 
> Ok, will remove the strcmp then.
> 
> > Does the patch mean we inlined __builtin_alloca_with_align ()
> > functions?  We might run into the issue Eric fixed lately with
> 
> Yes, see testcase below.  4.7+ inlines it.  As for tail call optimization,
> seems we are just lucky there (f4), as fab pass which is quite late
> turns the __builtin_stack_restore into GIMPLE_NOP and tailc pass does not
> ignore nops.  Shall I commit following patch to trunk to fix that up
> (after committing this VLA fix of course)?

Yes please.

Thanks,
Richard.

> int f1 (char *);
> 
> static inline void
> f2 (int x)
> {
>   char a[x];
>   f1 (a);
> }
> 
> void
> f3 (int x)
> {
>   f2 (x);
>   f2 (x);
>   f2 (x);
>   f2 (x);
> }
> 
> int
> f4 (int x)
> {
>   char a[x];
>   return f1 (a);
> }
> 
> 2015-12-04  Jakub Jelinek  <jakub@redhat.com>
> 
> 	* tree-tailcall.c (find_tail_calls): Ignore GIMPLE_NOPs.
> 
> --- gcc/tree-tailcall.c.jj	2015-11-04 11:12:17.000000000 +0100
> +++ gcc/tree-tailcall.c	2015-12-04 11:43:01.296110941 +0100
> @@ -412,9 +412,10 @@ find_tail_calls (basic_block bb, struct
>      {
>        stmt = gsi_stmt (gsi);
>  
> -      /* Ignore labels, returns, clobbers and debug stmts.  */
> +      /* Ignore labels, returns, nops, clobbers and debug stmts.  */
>        if (gimple_code (stmt) == GIMPLE_LABEL
>  	  || gimple_code (stmt) == GIMPLE_RETURN
> +	  || gimple_code (stmt) == GIMPLE_NOP
>  	  || gimple_clobber_p (stmt)
>  	  || is_gimple_debug (stmt))
>  	continue;
> @@ -532,7 +533,8 @@ find_tail_calls (basic_block bb, struct
>  
>        stmt = gsi_stmt (agsi);
>  
> -      if (gimple_code (stmt) == GIMPLE_LABEL)
> +      if (gimple_code (stmt) == GIMPLE_LABEL
> +	  || gimple_code (stmt) == GIMPLE_NOP)
>  	continue;
>  
>        if (gimple_code (stmt) == GIMPLE_RETURN)
> 
> 
> 	Jakub
> 
>
diff mbox

Patch

--- gcc/tree-tailcall.c.jj	2015-11-04 11:12:17.000000000 +0100
+++ gcc/tree-tailcall.c	2015-12-04 11:43:01.296110941 +0100
@@ -412,9 +412,10 @@  find_tail_calls (basic_block bb, struct
     {
       stmt = gsi_stmt (gsi);
 
-      /* Ignore labels, returns, clobbers and debug stmts.  */
+      /* Ignore labels, returns, nops, clobbers and debug stmts.  */
       if (gimple_code (stmt) == GIMPLE_LABEL
 	  || gimple_code (stmt) == GIMPLE_RETURN
+	  || gimple_code (stmt) == GIMPLE_NOP
 	  || gimple_clobber_p (stmt)
 	  || is_gimple_debug (stmt))
 	continue;
@@ -532,7 +533,8 @@  find_tail_calls (basic_block bb, struct
 
       stmt = gsi_stmt (agsi);
 
-      if (gimple_code (stmt) == GIMPLE_LABEL)
+      if (gimple_code (stmt) == GIMPLE_LABEL
+	  || gimple_code (stmt) == GIMPLE_NOP)
 	continue;
 
       if (gimple_code (stmt) == GIMPLE_RETURN)