From: Jeff Law <law@redhat.com>
To: gcc-patches <gcc-patches@gcc.gnu.org>
Subject: [PATCH][PR tree-optimization/79578] Use operand_equal_p rather than pointer equality for base test
Date: Thu, 23 Feb 2017 05:59:00 -0000 [thread overview]
Message-ID: <5d9c026a-12a7-d6f7-e1d7-da0382ac8f2a@redhat.com> (raw)
[-- 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)
next reply other threads:[~2017-02-23 5:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-23 5:59 Jeff Law [this message]
2017-02-23 9:44 ` Richard Biener
2017-02-23 21:27 ` Jeff Law
2017-02-24 10:05 ` Richard Biener
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5d9c026a-12a7-d6f7-e1d7-da0382ac8f2a@redhat.com \
--to=law@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).