Bug 36326 - gimplification of aggregate copies introduces extra aggregate copy
Summary: gimplification of aggregate copies introduces extra aggregate copy
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.4.0
: P3 normal
Target Milestone: 4.4.0
Assignee: Not yet assigned to anyone
URL:
Keywords: missed-optimization
Depends on:
Blocks: 17526
  Show dependency treegraph
 
Reported: 2008-05-25 16:31 UTC by Richard Biener
Modified: 2008-05-28 08:05 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Biener 2008-05-25 16:31:34 UTC
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.
Comment 1 Richard Biener 2008-05-25 16:47:21 UTC
Caused by the fix for PR17526.
Comment 2 Richard Biener 2008-05-25 17:18:33 UTC
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.
Comment 3 Michael Matz 2008-05-27 14:28:53 UTC
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

Comment 4 Drea Pinski 2008-05-28 08:05:30 UTC
Fixed.
Comment 5 Richard Biener 2008-12-03 15:11:27 UTC
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