re PR rtl-optimization/84003 (FAIL: g++.dg/torture/pr77745.C with noinline foo)
authorRichard Biener <rguenther@suse.de>
Fri, 26 Jan 2018 14:50:25 +0000 (14:50 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 26 Jan 2018 14:50:25 +0000 (14:50 +0000)
2018-01-26  Richard Biener  <rguenther@suse.de>

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
gcc/dse.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/torture/pr77745-2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/torture/pr77745.C

index 764368ae20accd01b670a824bd295baaa8a4fa00..2f6426927a5102b8ddd6aa2c7b506c9109f3fb9b 100644 (file)
@@ -1,3 +1,9 @@
+2018-01-26  Richard Biener  <rguenther@suse.de>
+
+       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  <jakub@redhat.com>
 
        PR rtl-optimization/83985
index a0c66aa75ab470824cdf43276d5296ee4824bb10..1ef8f642719f7b16ae517557618e51a6c4fde43c 100644 (file)
--- 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)
                {
index 65bfe0fc4400849804a7d4c185c3733e3179e493..92bbe451eb16c7a0ae642816c9f934d9ebfd0f52 100644 (file)
@@ -1,3 +1,11 @@
+2018-01-26  Richard Biener  <rguenther@suse.de>
+
+       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  <kyrylo.tkachov@arm.com>
 
        * 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 (file)
index 0000000..7861089
--- /dev/null
@@ -0,0 +1,4 @@
+// { dg-do run }
+
+#define NOINLINE __attribute__((noinline))
+#include "pr77745.C"
index 59d86b5c501ef38f52c20010fce6f7042ca6840a..6285bc14a43ba7bd9ab7387dc51588a352357ed9 100644 (file)
@@ -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;