]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR rtl-optimization/58365
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 10 Sep 2013 11:47:19 +0000 (11:47 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 10 Sep 2013 11:47:19 +0000 (11:47 +0000)
* cfgcleanup.c (merge_memattrs): Also clear MEM_READONLY_P
resp. MEM_NOTRAP_P if they differ, or set MEM_VOLATILE_P if
it differs.

* gcc.c-torture/execute/pr58365.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@202434 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/cfgcleanup.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/pr58365.c [new file with mode: 0644]

index 829d60a872e6d73f2f2a5c9012675ff8907c898d..cd91607f9b78bef9f3cc495219ce695946d201e6 100644 (file)
@@ -1,3 +1,10 @@
+2013-09-10  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/58365
+       * cfgcleanup.c (merge_memattrs): Also clear MEM_READONLY_P
+       resp. MEM_NOTRAP_P if they differ, or set MEM_VOLATILE_P if
+       it differs.
+
 2013-09-10  Richard Biener  <rguenther@suse.de>
 
        * tree-data-ref.h (build_rdg): Drop all parameters but loop.
index 6836a9e6e847ac513e5f5de39fcd776e50d48449..e88fe2ed500c3aa78663c79f20f046adbe12a32f 100644 (file)
@@ -925,6 +925,24 @@ merge_memattrs (rtx x, rtx y)
          set_mem_align (y, MEM_ALIGN (x));
        }
     }
+  if (code == MEM)
+    {
+      if (MEM_READONLY_P (x) != MEM_READONLY_P (y))
+       {
+         MEM_READONLY_P (x) = 0;
+         MEM_READONLY_P (y) = 0;
+       }
+      if (MEM_NOTRAP_P (x) != MEM_NOTRAP_P (y))
+       {
+         MEM_NOTRAP_P (x) = 0;
+         MEM_NOTRAP_P (y) = 0;
+       }
+      if (MEM_VOLATILE_P (x) != MEM_VOLATILE_P (y))
+       {
+         MEM_VOLATILE_P (x) = 1;
+         MEM_VOLATILE_P (y) = 1;
+       }
+    }
 
   fmt = GET_RTX_FORMAT (code);
   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
index a10988796c0e93e66a252a9f0a96666c1aebda2f..fe91b24808fbbafdd8d84c139bcf227e8145291e 100644 (file)
@@ -1,3 +1,8 @@
+2013-09-10  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/58365
+       * gcc.c-torture/execute/pr58365.c: New test.
+
 2013-09-10  Michael Zolotukhin  <michael.v.zolotukhin@gmail.com>
 
        * gcc.dg/torture/memcpy-1.c: New test.
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr58365.c b/gcc/testsuite/gcc.c-torture/execute/pr58365.c
new file mode 100644 (file)
index 0000000..1e6079d
--- /dev/null
@@ -0,0 +1,35 @@
+/* PR rtl-optimization/58365 */
+
+extern void abort (void);
+
+struct S
+{
+  volatile int a;
+  int b, c, d, e;
+} f;
+static struct S g, h;
+int i = 1;
+
+char
+foo (void)
+{
+  return i;
+}
+
+static struct S
+bar (void)
+{
+  if (foo ())
+    return f;
+  return g;
+}
+
+int
+main ()
+{
+  h = bar ();
+  f.b = 1;
+  if (h.b != 0)
+    abort ();
+  return 0;
+}