@@ -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
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))
@@ -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;
+}
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 <jakub@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. Jakub