* 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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@185918
138bc75d-0d04-0410-961f-
82ee72b054a4
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.
--- /dev/null
+/* 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" } } */
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)