Bug 45970 - tree DSE misses many obvious dead stores
Summary: tree DSE misses many obvious dead stores
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.6.0
: P3 enhancement
Target Milestone: 4.6.0
Assignee: Richard Biener
URL:
Keywords: missed-optimization
Depends on:
Blocks:
 
Reported: 2010-10-11 14:40 UTC by Jakub Jelinek
Modified: 2010-10-13 13:03 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2010-10-11 14:48:15


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jakub Jelinek 2010-10-11 14:40:09 UTC
struct A { char c[4]; } a, b;

void
f1 (void)
{
  __builtin_memcpy (&a.c[0], "a", 1);
  a = b;
}

void
f2 (void)
{
  __builtin_memcpy (&a.c[0], "a", 1);
  __builtin_memcpy (&a.c[0], "cdef", 4);
}

isn't optimized by tree DSE.  RTL DSE can handle it, but only on some targets (there are issues with calls to builtins if they were expanded as calls and args aren't in registers etc.).
Comment 1 Richard Biener 2010-10-11 14:48:15 UTC
Confirmed, mine.
Comment 2 Richard Biener 2010-10-13 13:03:37 UTC
Author: rguenth
Date: Wed Oct 13 13:03:31 2010
New Revision: 165422

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=165422
Log:
2010-10-13  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/45970
	* tree-ssa-alias.h (stmt_kills_ref_p): Declare.
	* tree-ssa-alias.c (stmt_kills_ref_p_1): New function.
	(stmt_kills_ref_p): Likewise.
	* tree-ssa-dse.c (dse_optimize_stmt): Use it.

	* gcc.dg/tree-ssa/ssa-dse-13.c: New testcase.

Added:
    trunk/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-13.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-ssa-alias.c
    trunk/gcc/tree-ssa-alias.h
    trunk/gcc/tree-ssa-dse.c
Comment 3 Richard Biener 2010-10-13 13:03:58 UTC
Fixed on trunk.