From: Jakub Jelinek Date: Tue, 10 Sep 2013 11:47:19 +0000 (+0200) Subject: re PR rtl-optimization/58365 (likely wrong code bug) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;ds=sidebyside;h=84cf4ab655292038d1371a801cbffb9fc6b6ecd0;hp=447dd9066575a8b92bd0369b809978f71a5235e5;p=gcc.git re PR rtl-optimization/58365 (likely wrong code bug) 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. * gcc.c-torture/execute/pr58365.c: New test. From-SVN: r202434 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 829d60a872e..cd91607f9b7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2013-09-10 Jakub Jelinek + + 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 * tree-data-ref.h (build_rdg): Drop all parameters but loop. diff --git a/gcc/cfgcleanup.c b/gcc/cfgcleanup.c index 6836a9e6e84..e88fe2ed500 100644 --- a/gcc/cfgcleanup.c +++ b/gcc/cfgcleanup.c @@ -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--) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a10988796c0..fe91b24808f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2013-09-10 Jakub Jelinek + + PR rtl-optimization/58365 + * gcc.c-torture/execute/pr58365.c: New test. + 2013-09-10 Michael Zolotukhin * 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 index 00000000000..1e6079d8429 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr58365.c @@ -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; +}