On Wed, Mar 28, 2012 at 4:00 PM, Jakub Jelinek <ja...@redhat.com> wrote: > Hi! > > The builtin_decl_explicit_p changes broke the __builtin_va_start > -> __builtin_next_arg folding, previously it was testing that > built_in_decls[BUILT_IN_NEXT_ARG] == NULL (and giving up in that case), > so the conversion missed !. > > Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, > ok for trunk/4.7?
Ok. Thanks, Richard. > 2012-03-28 Jakub Jelinek <ja...@redhat.com> > > PR middle-end/52691 > * tree-ssa-ccp.c (optimize_stdarg_builtin): Optimize > __builtin_va_start to __builtin_next_arg if the latter is > builtin_decl_explicit_p rather than when it is not. > > * gcc.dg/pr52691.c: New test. > > --- gcc/tree-ssa-ccp.c.jj 2012-01-13 21:47:35.000000000 +0100 > +++ gcc/tree-ssa-ccp.c 2012-03-28 12:48:44.358615418 +0200 > @@ -2288,7 +2288,7 @@ optimize_stdarg_builtin (gimple call) > case BUILT_IN_VA_START: > if (!va_list_simple_ptr > || targetm.expand_builtin_va_start != NULL > - || builtin_decl_explicit_p (BUILT_IN_NEXT_ARG)) > + || !builtin_decl_explicit_p (BUILT_IN_NEXT_ARG)) > return NULL_TREE; > > if (gimple_call_num_args (call) != 2) > --- gcc/testsuite/gcc.dg/pr52691.c.jj 2012-03-28 12:57:34.555364325 +0200 > +++ gcc/testsuite/gcc.dg/pr52691.c 2012-03-28 13:11:16.020328633 +0200 > @@ -0,0 +1,24 @@ > +/* PR middle-end/52691 */ > +/* { dg-do compile } */ > +/* { dg-options "-O2 -fdump-tree-optimized" } */ > + > +#include <stdarg.h> > + > +int > +foo (int a, ...) > +{ > + int b = 0, c = 0; > + va_list ap; > + va_start (ap, a); > + if (a > 1) > + b = va_arg (ap, double); > + if (a > 2) > + c = va_arg (ap, long long); > + va_end (ap); > + return a + b + c; > +} > + > +/* { dg-final { scan-tree-dump "__builtin_next_arg" "optimized" { target { { > i?86-*-* x86_64-*-* } && ia32 } } } } */ > +/* { dg-final { scan-tree-dump "__builtin_next_arg" "optimized" { target { > powerpc*-*-darwin* powerpc*-*-aix* } } } } */ > +/* { dg-final { scan-tree-dump "__builtin_next_arg" "optimized" { target { > powerpc*-*-linux* && lp64 } } } } */ > +/* { dg-final { cleanup-tree-dump "optimized" } } */ > > Jakub