On Wed, Jan 25, 2012 at 01:18:28PM +0100, Richard Guenther wrote:
> Yes, that's ok with me.  For the rest you can file an enhancement PR.

Ok, here is what I've committed, and I'll file the PR momentarily.

2012-01-25  Jakub Jelinek  <ja...@redhat.com>

        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.

--- gcc/tree-data-ref.c.jj      2012-01-25 13:30:51.563590373 +0100
+++ gcc/tree-data-ref.c 2012-01-25 13:34:12.323973880 +0100
@@ -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 <p...@cri.ensmp.fr>
 
@@ -4185,7 +4185,7 @@ get_references_in_stmt (gimple stmt, VEC
   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))
--- gcc/testsuite/gcc.target/i386/pr51987.c.jj  2012-01-24 23:32:44.887896707 
+0100
+++ gcc/testsuite/gcc.target/i386/pr51987.c     2012-01-24 23:34:26.289296794 
+0100
@@ -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;
+}


        Jakub

Reply via email to