re PR tree-optimization/51987 (Predictive commoning wrong-code with non-volatile...
authorJakub Jelinek <jakub@redhat.com>
Wed, 25 Jan 2012 15:38:51 +0000 (16:38 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 25 Jan 2012 15:38:51 +0000 (16:38 +0100)
PR tree-optimization/51987
* tree-data-ref.c (get_references_in_stmt): Handle references in
non-volatile GIMPLE_ASM.

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

From-SVN: r183524

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr51987.c [new file with mode: 0644]
gcc/tree-data-ref.c

index a671f6931114f940c2cb3688acb2c483e49ec013..b3be4c013690c40351a87ab945580aed098a2264 100644 (file)
@@ -1,3 +1,9 @@
+2012-01-25  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/51987
+       * tree-data-ref.c (get_references_in_stmt): Handle references in
+       non-volatile GIMPLE_ASM.
+
 2012-01-25  Richard Guenther  <rguenther@suse.de>
 
        * tree-ssa-sccvn.c (vn_reference_eq): Also compare if both
index c207146fd587e8617fb4256ccbd30751932a5b16..ea0cc24800f9f843c9036389cabe08fca30cf714 100644 (file)
@@ -1,3 +1,8 @@
+2012-01-25  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/51987
+       * gcc.target/i386/pr51987.c: New test.
+
 2012-01-25  Greta Yorsh  <Greta.Yorsh@arm.com>
 
        * gcc.dg/tm/lto-1.c: Require lto support in target.
diff --git a/gcc/testsuite/gcc.target/i386/pr51987.c b/gcc/testsuite/gcc.target/i386/pr51987.c
new file mode 100644 (file)
index 0000000..6ac2e63
--- /dev/null
@@ -0,0 +1,33 @@
+/* PR tree-optimization/51987 */
+/* { dg-do run { target { ! { ia32 } } } } */
+/* { dg-options "-O3" } */
+
+extern void abort (void);
+union U { unsigned long long l; struct { unsigned int l, h; } i; };
+
+__attribute__((noinline, noclone)) void
+foo (char *x, char *y)
+{
+  int i;
+  for (i = 0; i < 64; i++)
+    {
+      union U u;
+      asm ("movl %1, %k0; salq $32, %0" : "=r" (u.l) : "r" (i));
+      x[i] = u.i.h;
+      union U v;
+      asm ("movl %1, %k0; salq $32, %0" : "=r" (v.l) : "r" (i));
+      y[i] = v.i.h;
+    }
+}
+
+int
+main ()
+{
+  char a[64], b[64];
+  int i;
+  foo (a, b);
+  for (i = 0; i < 64; i++)
+    if (a[i] != i || b[i] != i)
+      abort ();
+  return 0;
+}
index a0d86ec9c117572dbcbe73df4e9250ebbe56df5d..09929c79ebf23bb7f81d13b60a32a4d8dad0cca9 100644 (file)
@@ -1,5 +1,5 @@
 /* Data references and dependences detectors.
-   Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
+   Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
    Free Software Foundation, Inc.
    Contributed by Sebastian Pop <pop@cri.ensmp.fr>
 
@@ -4185,7 +4185,7 @@ get_references_in_stmt (gimple stmt, VEC (data_ref_loc, heap) **references)
   if ((stmt_code == GIMPLE_CALL
        && !(gimple_call_flags (stmt) & (ECF_CONST | ECF_PURE)))
       || (stmt_code == GIMPLE_ASM
-         && gimple_asm_volatile_p (stmt)))
+         && (gimple_asm_volatile_p (stmt) || gimple_vuse (stmt))))
     clobbers_memory = true;
 
   if (!gimple_vuse (stmt))