From 14a43348bc523d889df7918ae8672b233b2ccf37 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 24 Aug 2007 14:29:14 +0200 Subject: expr.c (store_expr): Optimize initialization of an array with STRING_CST. * expr.c (store_expr): Optimize initialization of an array with STRING_CST. * expr.h (builtin_strncpy_read_str): New prototype. * builtins.c (builtin_strncpy_read_str): Remove prototype. No longer static. * gcc.dg/array-init-1.c: New test. From-SVN: r127769 --- gcc/testsuite/gcc.dg/array-init-1.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/array-init-1.c (limited to 'gcc/testsuite/gcc.dg/array-init-1.c') diff --git a/gcc/testsuite/gcc.dg/array-init-1.c b/gcc/testsuite/gcc.dg/array-init-1.c new file mode 100644 index 0000000..8b866cc --- /dev/null +++ b/gcc/testsuite/gcc.dg/array-init-1.c @@ -0,0 +1,24 @@ +/* Test that both arrays are initialized by store_by_pieces. */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +struct A { char c[10]; }; +extern void baz (struct A *); + +void +foo (void) +{ + struct A a = { "abcdefghi" }; + baz (&a); +} + +void +bar (void) +{ + struct A a; + __builtin_strcpy (&a.c[0], "abcdefghi"); + baz (&a); +} + +/* { dg-final { scan-assembler-not "abcdefghi" { target i?86-*-* x86_64-*-* ia64-*-* } } } */ +/* { dg-final { scan-assembler-times "7523094288207667809\|6867666564636261\|1684234849\|64636261" 2 { target i?86-*-* x86_64-*-* ia64-*-* } } } */ -- cgit v1.1