public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH][PR tree-optimization/79578] Use operand_equal_p rather than pointer equality for base test
@ 2017-02-23  5:59 Jeff Law
  2017-02-23  9:44 ` Richard Biener
  0 siblings, 1 reply; 4+ messages in thread
From: Jeff Law @ 2017-02-23  5:59 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 321 bytes --]


tree-ssa-dse.c needs to verify when two writes have the same base 
address.  Right now it uses pointer equality.  The testcase in BZ79578 
shows that we should have been using operand_equal_p.

This one-liner fixes that oversight.  Bootstrapped and regression tested 
on x86_64-linux-gnu.  Installed on the trunk.

Jeff

[-- Attachment #2: P --]
[-- Type: text/plain, Size: 2484 bytes --]

commit ef506ec9114a7fe27d9ee892c17edd100f72a963
Author: law <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Thu Feb 23 05:47:43 2017 +0000

    	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.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@245675 138bc75d-0d04-0410-961f-82ee72b054a4

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 7155850..6da1d74 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index ea5e251..d900cc3 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 0000000..fe8f309
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tree-ssa/ssa-dse-3.C
@@ -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" } } */
+
diff --git a/gcc/tree-ssa-dse.c b/gcc/tree-ssa-dse.c
index 84c0b11..a82e164 100644
--- a/gcc/tree-ssa-dse.c
+++ b/gcc/tree-ssa-dse.c
@@ -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)

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-02-24 10:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-23  5:59 [PATCH][PR tree-optimization/79578] Use operand_equal_p rather than pointer equality for base test Jeff Law
2017-02-23  9:44 ` Richard Biener
2017-02-23 21:27   ` Jeff Law
2017-02-24 10:05     ` Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).