From d7e1f499ed046bd1d57eaf4510778d2fc2666653 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Fri, 26 Jan 2018 14:50:25 +0000 Subject: [PATCH] re PR rtl-optimization/84003 (FAIL: g++.dg/torture/pr77745.C with noinline foo) 2018-01-26 Richard Biener PR rtl-optimization/84003 * dse.c (record_store): Only record redundant stores when the earlier store aliases at least all accesses the later one does. * g++.dg/torture/pr77745.C: Mark foo noinline to trigger latent bug in DSE if NOINLINE is appropriately defined. * g++.dg/torture/pr77745-2.C: New testcase including pr77745.C and defining NOINLINE. From-SVN: r257091 --- gcc/ChangeLog | 6 ++++++ gcc/dse.c | 7 ++++++- gcc/testsuite/ChangeLog | 8 ++++++++ gcc/testsuite/g++.dg/torture/pr77745-2.C | 4 ++++ gcc/testsuite/g++.dg/torture/pr77745.C | 6 +++++- 5 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/torture/pr77745-2.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 764368ae20a..2f6426927a5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2018-01-26 Richard Biener + + PR rtl-optimization/84003 + * dse.c (record_store): Only record redundant stores when + the earlier store aliases at least all accesses the later one does. + 2018-01-26 Jakub Jelinek PR rtl-optimization/83985 diff --git a/gcc/dse.c b/gcc/dse.c index a0c66aa75ab..1ef8f642719 100644 --- a/gcc/dse.c +++ b/gcc/dse.c @@ -1532,7 +1532,12 @@ record_store (rtx body, bb_info_t bb_info) && known_subrange_p (offset, width, s_info->offset, s_info->width) && all_positions_needed_p (s_info, offset - s_info->offset, - width)) + width) + /* We can only remove the later store if the earlier aliases + at least all accesses the later one. */ + && (MEM_ALIAS_SET (mem) == MEM_ALIAS_SET (s_info->mem) + || alias_set_subset_of (MEM_ALIAS_SET (mem), + MEM_ALIAS_SET (s_info->mem)))) { if (GET_MODE (mem) == BLKmode) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 65bfe0fc440..92bbe451eb1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2018-01-26 Richard Biener + + PR rtl-optimization/84003 + * g++.dg/torture/pr77745.C: Mark foo noinline to trigger + latent bug in DSE if NOINLINE is appropriately defined. + * g++.dg/torture/pr77745-2.C: New testcase including pr77745.C + and defining NOINLINE. + 2018-01-26 Kyrylo Tkachov * gcc.target/aarch64/advsimd-intrinsics/vld1x2.c: Make float64 diff --git a/gcc/testsuite/g++.dg/torture/pr77745-2.C b/gcc/testsuite/g++.dg/torture/pr77745-2.C new file mode 100644 index 00000000000..7861089a817 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr77745-2.C @@ -0,0 +1,4 @@ +// { dg-do run } + +#define NOINLINE __attribute__((noinline)) +#include "pr77745.C" diff --git a/gcc/testsuite/g++.dg/torture/pr77745.C b/gcc/testsuite/g++.dg/torture/pr77745.C index 59d86b5c501..6285bc14a43 100644 --- a/gcc/testsuite/g++.dg/torture/pr77745.C +++ b/gcc/testsuite/g++.dg/torture/pr77745.C @@ -1,8 +1,12 @@ // { dg-do run } +#ifndef NOINLINE +#define NOINLINE /* */ +#endif + inline void* operator new(__SIZE_TYPE__, void* __p) noexcept { return __p; } -long foo(char *c1, char *c2) +long NOINLINE foo(char *c1, char *c2) { long *p1 = new (c1) long; *p1 = 100; -- 2.30.2