summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2018-02-16 07:56:16 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2018-02-16 07:56:16 +0000
commit606f008bed9783d2775d5c071f5361ba55904683 (patch)
tree7b31d1caca27355a4224431eef869f63a0bdf4b1
parent7238ae962fbc16a752efad42931d43cbe4764d75 (diff)
downloadgcc-606f008bed9783d2775d5c071f5361ba55904683.tar.gz
2018-02-16 Richard Biener <rguenther@suse.de>
PR tree-optimization/84190 * tree-ssa.c (non_rewritable_mem_ref_base): Do not touch volatile accesses if the decl isn't volatile. * g++.dg/torture/pr84190.C: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@257721 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/torture/pr84190.C20
-rw-r--r--gcc/tree-ssa.c3
4 files changed, 33 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 4062532e804..8ca7fba1714 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2018-02-16 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/84190
+ * tree-ssa.c (non_rewritable_mem_ref_base): Do not touch
+ volatile accesses if the decl isn't volatile.
+
2018-02-15 Jason Merrill <jason@redhat.com>
PR c++/84314 - ICE with templates and fastcall attribute.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 11da4b2caff..8c0e0f0d97d 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2018-02-16 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/84190
+ * g++.dg/torture/pr84190.C: New testcase.
+
2018-02-15 Martin Sebor <msebor@redhat.com>
* gcc.dg/lto/README (dg-lto-warning, dg-lto-message): Document new
diff --git a/gcc/testsuite/g++.dg/torture/pr84190.C b/gcc/testsuite/g++.dg/torture/pr84190.C
new file mode 100644
index 00000000000..a7bab944365
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr84190.C
@@ -0,0 +1,20 @@
+// { dg-do compile }
+// For slim LTO there's no optimized dump
+// { dg-skip-if "" { *-*-* } { "-flto" } { "" } }
+// { dg-additional-options "-fdump-tree-optimized" }
+
+typedef double T;
+static int equalfn (volatile T* x, volatile T* y);
+T gx, gy;
+int main ()
+{
+ T x = gx, y = gy;
+ return equalfn (&x, &y);
+}
+static int equalfn (volatile T* x, volatile T* y)
+{
+ return (*x == *y);
+}
+
+// There should be exactly two volatile accesses (ignoring clobbers).
+// { dg-final { scan-tree-dump-times " ={v} \[^\{\]" 2 "optimized" } }
diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c
index ee311ce9758..949b951e1aa 100644
--- a/gcc/tree-ssa.c
+++ b/gcc/tree-ssa.c
@@ -1427,7 +1427,8 @@ non_rewritable_mem_ref_base (tree ref)
if (! DECL_P (decl))
return NULL_TREE;
if (! is_gimple_reg_type (TREE_TYPE (base))
- || VOID_TYPE_P (TREE_TYPE (base)))
+ || VOID_TYPE_P (TREE_TYPE (base))
+ || TREE_THIS_VOLATILE (decl) != TREE_THIS_VOLATILE (base))
return decl;
if ((TREE_CODE (TREE_TYPE (decl)) == VECTOR_TYPE
|| TREE_CODE (TREE_TYPE (decl)) == COMPLEX_TYPE)