re PR c/84190 (double arithmetic on x86 no longer rounds to nearest)
authorRichard Biener <rguenther@suse.de>
Fri, 16 Feb 2018 07:56:16 +0000 (07:56 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 16 Feb 2018 07:56:16 +0000 (07:56 +0000)
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.

From-SVN: r257721

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

index 4062532e80477f2b9501aa9faa1902083332c212..8ca7fba1714568428846c91fb655ce70636fc50a 100644 (file)
@@ -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.
index 11da4b2caff917f445fbdefe26768b94ef24e96f..8c0e0f0d97dd624ee8d8fe058cd2828467279967 100644 (file)
@@ -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 (file)
index 0000000..a7bab94
--- /dev/null
@@ -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" } }
index ee311ce9758c193a663b25e5d9e2b4c98a71daab..949b951e1aaa98ccda0f769fde392a6809d70bcc 100644 (file)
@@ -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)