re PR tree-optimization/79578 (Unnecessary instructions in generated code)
authorJeff Law <law@redhat.com>
Thu, 23 Feb 2017 05:47:43 +0000 (22:47 -0700)
committerJeff Law <law@gcc.gnu.org>
Thu, 23 Feb 2017 05:47:43 +0000 (22:47 -0700)
PR tree-optimization/79578
* tree-ssa-dse.c (clear_bytes_written_by): Use operand_equal_p
to compare base operands.

PR tree-optimization/79578
* g++.dg/tree-ssa/ssa-dse-3.C: New test.

From-SVN: r245675

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/tree-ssa/ssa-dse-3.C [new file with mode: 0644]
gcc/tree-ssa-dse.c

index 7155850e3a9e9e593965cc8fb12782a45936cd44..6da1d74115f18b879d5f90853d0dd72b7d127ac5 100644 (file)
@@ -1,3 +1,9 @@
+2017-02-22 Jeff Law  <law@redhat.com>
+
+       PR tree-optimization/79578
+       * tree-ssa-dse.c (clear_bytes_written_by): Use operand_equal_p
+       to compare base operands.
+
 2017-02-22  Segher Boessenkool  <segher@kernel.crashing.org>
 
        PR target/79211
index ea5e2515d8652ef5423dde24b22acb2e7431dfc8..d900cc3496ba6e8ac1a3334958cddd13dd6a01f0 100644 (file)
@@ -1,3 +1,8 @@
+2017-02-22  Jeff Law  <law@redhat.com>
+
+       PR tree-optimization/79578
+       * g++.dg/tree-ssa/ssa-dse-3.C: New test.
+
 2017-02-22  Sameera Deshpande  <sameera.deshpande@imgtec.com>
 
        * gcc.target/mips/msa-fp-cc.c: New test.
diff --git a/gcc/testsuite/g++.dg/tree-ssa/ssa-dse-3.C b/gcc/testsuite/g++.dg/tree-ssa/ssa-dse-3.C
new file mode 100644 (file)
index 0000000..fe8f309
--- /dev/null
@@ -0,0 +1,28 @@
+/* { dg-do compile } */
+/* { dg-options "-std=c++14 -O3 -fdump-tree-dse1-details" } */
+
+#include <new>
+#include <cstdint>
+
+struct A
+{
+    std::uint16_t a, b;
+};
+
+A* f(char* b) __attribute__((noinline));
+
+A* f(char* b) {
+    auto a = new(b) A{};
+    a->a = 1;
+    a->b = 2;
+    return a;
+}
+
+int main() {
+    char b[sizeof(A)] alignas(A);
+    f(b);
+}
+
+
+/* { dg-final { scan-tree-dump "Deleted dead store: " "dse1" } } */
+
index 84c0b11f53b87340194ff59d664028d856a94a38..a82e16449c49ad93914a27df525e05c00e8c1680 100644 (file)
@@ -176,7 +176,7 @@ clear_bytes_written_by (sbitmap live_bytes, gimple *stmt, ao_ref *ref)
   /* Verify we have the same base memory address, the write
      has a known size and overlaps with REF.  */
   if (valid_ao_ref_for_dse (&write)
-      && write.base == ref->base
+      && operand_equal_p (write.base, ref->base, 0)
       && write.size == write.max_size
       && ((write.offset < ref->offset
           && write.offset + write.size > ref->offset)