Commit f25a65f5 by Jakub Jelinek Committed by Jakub Jelinek

re PR middle-end/52691 (va_start to builtin_next_arg optimization lost)

	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.

From-SVN: r185917
parent 6df000ae
2012-03-28 Jakub Jelinek <jakub@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.
PR middle-end/52750
* tree-vect-generic.c (vector_element): Perform multiplication
for pos in bitsizetype type instead of idx type.
......
2012-03-28 Jakub Jelinek <jakub@redhat.com>
PR middle-end/52691
* gcc.dg/pr52691.c: New test.
PR middle-end/52750
* gcc.c-torture/compile/pr52750.c: New test.
......
/* 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" } } */
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment