At -O2 we should IMNSHO generate the same code for all 3 functions: typedef union { struct { int f1, f2, f3, f4, f5, f6, f7, f8; long int f9, f10; int f11; } f; char s[56]; long int a; } T; void foo (void) { T t; t = (T) { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }; test (&t); } void bar (void) { T t = { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }; test (&t); } void baz (void) { T t; t = (const T) { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }; test (&t); } as nothing took the address of the compound literals, it was only used as initializer to some other variable. But instead foo/baz clear a temporary (compound literal var) and then copy it over. This is at least partly a regression from 3.2.x which cleared both the compound literal variable (wasn't able to DSE it) and the t variable. Without a union we generate better code: typedef struct { int f1, f2, f3, f4, f5, f6, f7, f8; long int f9, f10; int f11; } T; void foo (void) { T t; t = (T) { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; test (&t); } void bar (void) { T t = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; test (&t); } void baz (void) { T t; t = (const T) { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; test (&t); } but still bar uses on x86_64-linux rep stosq, while the other functions store it by pieces.
Confirmed.
Subject: Bug 33723 Author: jakub Date: Mon Oct 29 22:26:59 2007 New Revision: 129743 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=129743 Log: PR tree-optimization/33723 * c-gimplify.c (c_gimplify_expr): Optimize INIT_EXPR or MODIFY_EXPR with non-addressable COMPOUND_LITERAL_EXPR as source. * gcc.c-torture/execute/20071029-1.c: New test. * gcc.dg/tree-ssa/pr33723.c: New test. Added: trunk/gcc/testsuite/gcc.c-torture/execute/20071029-1.c trunk/gcc/testsuite/gcc.dg/tree-ssa/pr33723.c Modified: trunk/gcc/ChangeLog trunk/gcc/c-gimplify.c trunk/gcc/testsuite/ChangeLog
Fixed on the trunk so far.
Subject: Bug 33723 Author: jakub Date: Tue Oct 30 13:29:57 2007 New Revision: 129772 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=129772 Log: PR tree-optimization/33723 * gcc.dg/tree-ssa/pr33723.c (T): Decrease size of field s. Modified: trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/gcc.dg/tree-ssa/pr33723.c
Closing 4.1 branch.
Closing 4.2 branch, fixed in 4.3.