re PR middle-end/45852 (volatile structs are broken!)
authorJakub Jelinek <jakub@redhat.com>
Tue, 21 Dec 2010 08:35:16 +0000 (09:35 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 21 Dec 2010 08:35:16 +0000 (09:35 +0100)
PR middle-end/45852
* expr.c (store_expr): Ignore alt_rtl if equal to target,
but has side-effects.

* gcc.target/i386/pr45852.c: New test.

From-SVN: r168105

gcc/ChangeLog
gcc/expr.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr45852.c [new file with mode: 0644]

index b70ef95..e71e511 100644 (file)
@@ -1,3 +1,9 @@
+2010-12-21  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/45852
+       * expr.c (store_expr): Ignore alt_rtl if equal to target,
+       but has side-effects.
+
 2010-12-21  Anatoly Sokolov  <aesok@post.ru>
 
        * config/sh/sh.h (PREFERRED_RELOAD_CLASS): Remove.
index 56a6249..cd32f4f 100644 (file)
@@ -4712,7 +4712,10 @@ store_expr (tree exp, rtx target, int call_param_p, bool nontemporal)
       /* If store_expr stores a DECL whose DECL_RTL(exp) == TARGET,
         but TARGET is not valid memory reference, TEMP will differ
         from TARGET although it is really the same location.  */
-      && !(alt_rtl && rtx_equal_p (alt_rtl, target))
+      && !(alt_rtl
+          && rtx_equal_p (alt_rtl, target)
+          && !side_effects_p (alt_rtl)
+          && !side_effects_p (target))
       /* If there's nothing to copy, don't bother.  Don't call
         expr_size unless necessary, because some front-ends (C++)
         expr_size-hook must not be given objects that are not
index 029fa03..7b97962 100644 (file)
@@ -1,3 +1,8 @@
+2010-12-21  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/45852
+       * gcc.target/i386/pr45852.c: New test.
+
 2010-12-20  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/46974
diff --git a/gcc/testsuite/gcc.target/i386/pr45852.c b/gcc/testsuite/gcc.target/i386/pr45852.c
new file mode 100644 (file)
index 0000000..b0ba093
--- /dev/null
@@ -0,0 +1,16 @@
+/* PR middle-end/45852 */
+/* { dg-options "-O2 -mcmodel=small" } */
+/* { dg-do compile { target { { i?86-*-linux* x86_64-*-linux* } && lp64 } } } */
+/* { dg-require-visibility "" } */
+
+struct S { int s; };
+
+volatile struct S globvar __attribute__((visibility ("hidden"))) = { -6 };
+
+void
+foo (void)
+{
+  globvar = globvar;
+}
+
+/* { dg-final { scan-assembler-times "globvar.%?rip" 2 } } */