union X { int i; double x; }; int foo (union X *p) { union X x = *p; return x.x; } produces union X x.0; x.0 = *p; x = x.0; this is not optimized at any point. Using a struct instead usually SRA is able to remove the extra copy.
Caused by the fix for PR17526.
Which was just a workaround. It needs proper fixing so that Index: tree-gimple.c =================================================================== --- tree-gimple.c (revision 135859) +++ tree-gimple.c (working copy) @@ -116,10 +116,7 @@ is_gimple_mem_rhs (tree t) a renamed variable. Also force a temporary if the type doesn't need to be stored in memory, since it's cheap and prevents erroneous tailcalls (PR 17526). */ - if (is_gimple_reg_type (TREE_TYPE (t)) - || (TYPE_MODE (TREE_TYPE (t)) != BLKmode - && (TREE_CODE (t) != CALL_EXPR - || ! aggregate_value_p (t, t)))) + if (is_gimple_reg_type (TREE_TYPE (t))) return is_gimple_val (t); else return is_gimple_formal_tmp_rhs (t); doesn't regress.
Subject: Bug 36326 Author: matz Date: Tue May 27 14:28:02 2008 New Revision: 136033 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=136033 Log: PR middle-end/36326 * tree-gimple.c (is_gimple_mem_rhs): Remove work-around for non-BLKmode types. * tree-tailcall.c (find_tail_calls): Don't mark calls storing into memory as tail calls. Modified: trunk/gcc/ChangeLog trunk/gcc/tree-gimple.c trunk/gcc/tree-tailcall.c
Fixed.
Subject: Bug 36326 Author: rguenth Date: Wed Dec 3 15:10:03 2008 New Revision: 142396 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=142396 Log: 2008-12-03 Richard Guenther <rguenther@suse.de> PR middle-end/36326 * gimplify.c (is_gimple_mem_or_call_rhs): Remove work-around for non-BLKmode types. * gcc.dg/tree-ssa/pr36326.c: New testcase. Added: trunk/gcc/testsuite/gcc.dg/tree-ssa/pr36326.c Modified: trunk/gcc/ChangeLog trunk/gcc/gimplify.c trunk/gcc/testsuite/ChangeLog