Bug 35472 - [4.3 Regression] tree DSE is broken
Summary: [4.3 Regression] tree DSE is broken
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.3.0
: P2 normal
Target Milestone: 4.3.1
Assignee: Richard Biener
URL:
Keywords: wrong-code
Depends on: 34459
Blocks: 27799
  Show dependency treegraph
 
Reported: 2008-03-05 12:59 UTC by Richard Biener
Modified: 2008-03-07 09:49 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 4.2.3 4.4.0
Known to fail: 4.3.0
Last reconfirmed: 2008-03-05 13:19:22


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Biener 2008-03-05 12:59:58 UTC
extern void abort (void);
extern void *memset (void *s, int c, __SIZE_TYPE__ n);
struct S { int i[16]; };
struct S *p;
void __attribute__((noinline))
foo(struct S *a, struct S *b) { a->i[0] = -1; p = b; }
void test (void)
{
  struct S a, b;
  memset (&a.i[0], '\0', sizeof (a.i));
  memset (&b.i[0], '\0', sizeof (b.i));
  foo (&a, &b);
  *p = a;
  *p = b;
  if (b.i[0] != -1)
    abort ();
}
int main()
{
  test();
  return 0;
}

tree DSE removes the *p = a store wrongly.  Non-executable testcase:

struct S { int i[16]; };
struct S *p;
void foo(struct S *, struct S *);
void test (void)
{
  struct S a, b;
  foo (&a, &b);
  *p = a;
  *p = b;
}
Comment 1 Richard Biener 2008-03-05 14:45:08 UTC
We have

  # VUSE <p_7>
  p.0_1 = p;
  # a_11 = VDEF <a_8>
  # b_12 = VDEF <b_9>
  # SMT.5_13 = VDEF <SMT.5_10>
  *p.0_1 = a;
  # a_14 = VDEF <a_11>
  # b_15 = VDEF <b_12>
  # SMT.5_16 = VDEF <SMT.5_13>
  *p.0_1 = b;

This is actually a case of PR34459 and it is its testcase that actually
fails with the fix for PR27799.
Comment 2 Richard Biener 2008-03-05 14:56:24 UTC
Patch in testing.
Comment 3 Richard Biener 2008-03-05 16:13:46 UTC
Fixed on the trunk, waiting for 4.3.1.
Comment 4 Richard Biener 2008-03-05 16:13:49 UTC
Subject: Bug 35472

Author: rguenth
Date: Wed Mar  5 16:13:04 2008
New Revision: 132899

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=132899
Log:
2008-03-05  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/35472
	* tree-ssa-dse.c (dse_optimize_stmt): Do not delete a store
	whose single use_stmt has a overlapping set of loaded and
	stored symbols as that use_stmt might be a noop assignment then.

	* gcc.c-torture/execute/pr35472.c: New testcase.

Added:
    trunk/gcc/testsuite/gcc.c-torture/execute/pr35472.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-ssa-dse.c

Comment 5 Richard Biener 2008-03-07 09:47:51 UTC
Subject: Bug 35472

Author: rguenth
Date: Fri Mar  7 09:47:06 2008
New Revision: 133004

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=133004
Log:
2008-03-07  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/35472
	* tree-ssa-dse.c (dse_optimize_stmt): Do not delete a store
	whose single use_stmt has a overlapping set of loaded and
	stored symbols as that use_stmt might be a noop assignment then.

	* gcc.c-torture/execute/pr35472.c: New testcase.

Added:
    branches/gcc-4_3-branch/gcc/testsuite/gcc.c-torture/execute/pr35472.c
      - copied unchanged from r132899, trunk/gcc/testsuite/gcc.c-torture/execute/pr35472.c
Modified:
    branches/gcc-4_3-branch/gcc/ChangeLog
    branches/gcc-4_3-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_3-branch/gcc/tree-ssa-dse.c

Comment 6 Richard Biener 2008-03-07 09:49:27 UTC
Fixed.