aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAndrew Pinski <pinskia@physics.uc.edu>2005-02-26 16:15:25 +0000
committerAndrew Pinski <pinskia@gcc.gnu.org>2005-02-26 08:15:25 -0800
commitc529e0fe2e37607ee722881c877570fbc97143bd (patch)
tree80a8a0c3dfeb813ac7ba11261a533b6f84055b60 /gcc
parent54ff999a487c8e91f657b0ca873965099e2b312d (diff)
downloadgcc-c529e0fe2e37607ee722881c877570fbc97143bd.zip
gcc-c529e0fe2e37607ee722881c877570fbc97143bd.tar.gz
gcc-c529e0fe2e37607ee722881c877570fbc97143bd.tar.bz2
re PR tree-optimization/20188 (asm and memory operands does not add a V_MAY_DEF)
2005-02-26 Andrew Pinski <pinskia@physics.uc.edu> PR tree-opt/20188 * gcc.dg/tree-ssa/inline_asm-1.c: New test. * gcc.dg/tree-ssa/inline_asm-2.c: New test. * gcc.dg/asm-b.c: New test. 2005-02-26 Andrew Pinski <pinskia@physics.uc.edu> PR tree-opt/20188 * tree-ssa-alias.c (count_uses_and_derefs): If we have TREE_LIST for the lhs, also walk over the tree. Likewise for rhs. From-SVN: r95586
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/testsuite/ChangeLog7
-rw-r--r--gcc/testsuite/gcc.dg/asm-b.c39
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/inline_asm-1.c18
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/inline_asm-2.c17
-rw-r--r--gcc/tree-ssa-alias.c4
6 files changed, 89 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index dbff6a7..4b0fee5 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2005-02-26 Andrew Pinski <pinskia@physics.uc.edu>
+
+ PR tree-opt/20188
+ * tree-ssa-alias.c (count_uses_and_derefs): If we have TREE_LIST
+ for the lhs, also walk over the tree. Likewise for rhs.
+
2005-02-26 Zdenek Dvorak <dvorakz@suse.cz>
* tree-ssa-dom.c (simple_iv_increment_p): New function.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 6a89a20..9ab9ada 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2005-02-26 Andrew Pinski <pinskia@physics.uc.edu>
+
+ PR tree-opt/20188
+ * gcc.dg/tree-ssa/inline_asm-1.c: New test.
+ * gcc.dg/tree-ssa/inline_asm-2.c: New test.
+ * gcc.dg/asm-b.c: New test.
+
2005-02-26 Richard Sandiford <rsandifo@redhat.com>
* gcc.c-torture/execute/ieee/mul-subnormal-single-1.x: New file.
diff --git a/gcc/testsuite/gcc.dg/asm-b.c b/gcc/testsuite/gcc.dg/asm-b.c
new file mode 100644
index 0000000..ce68cab
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/asm-b.c
@@ -0,0 +1,39 @@
+/* { dg-do run { target powerpc-*-* i?386-*-* x86_64-*-* } } */
+/* { dg-options "-O1" } */
+/* Test to make sure that inline-asm causes the tree optimizators get the
+ V_MAY_DEFs and clober memory. */
+/* Test from Jakub Jelinek, modified by Andrew Pinski to work on all powerpc targets. */
+extern void abort (void);
+
+unsigned short v = 0x0300;
+
+void
+foo (unsigned short *p)
+{
+ *p = v;
+}
+
+int
+bar (void)
+{
+ unsigned short x;
+ volatile unsigned short *z;
+ foo (&x);
+ const unsigned int y = x;
+ z = &x;
+#if defined (__powerpc__) || defined (__PPC__) || defined (__ppc__) || defined (_POWER)
+ __asm __volatile ("sthbrx %1,0,%2" : "=m" (*z) : "r" (y), "r" (z));
+#elif defined __i386__ || defined __x86_64__
+ __asm __volatile ("movb %b1,1(%2); movb %h1,(%2)" : "=m" (*z) : "r" (y), "r"
+(z));
+#endif
+ return (x & 1) == 0;
+}
+
+int
+main (void)
+{
+ if (bar ())
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/inline_asm-1.c b/gcc/testsuite/gcc.dg/tree-ssa/inline_asm-1.c
new file mode 100644
index 0000000..4b241c3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/inline_asm-1.c
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-O1 -fdump-tree-optimized -fdump-tree-alias1-vops" } */
+/* Test to make sure that inline-asm causes a V_MAY_DEF and that we call test_function twice. */
+
+char test_function(void ) __attribute__((__pure__));
+char f(char *a)
+{
+ char b = test_function();
+ asm("":"=m"(*a):"r"(b));
+ b = test_function();
+ return b;
+}
+
+/* test_function should be called twice as the inline-asm changes memory. */
+/* { dg-final { scan-tree-dump-times "test_function" 2 "optimized"} } */
+
+/* There should a V_MAY_DEF for the inline-asm. */
+/* { dg-final { scan-tree-dump-times "V_MAY_DEF" 1 "alias1"} } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/inline_asm-2.c b/gcc/testsuite/gcc.dg/tree-ssa/inline_asm-2.c
new file mode 100644
index 0000000..bc4039f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/inline_asm-2.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-options "-O1 -fdump-tree-alias1-vops" } */
+/* Test to make sure that inline-asm causes a V_MAY_DEF. */
+
+
+void link_error();
+void f(char *a)
+{
+ int *a1 = (int *)a;
+ if (*a == 0)
+ asm("":"=m"(*a1));
+ if (*a == 0)
+ link_error ();
+}
+
+/* There should a V_MAY_DEF for the inline-asm. */
+/* { dg-final { scan-tree-dump-times "V_MAY_DEF" 1 "alias1"} } */
diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c
index f6cdf99..1adcd83 100644
--- a/gcc/tree-ssa-alias.c
+++ b/gcc/tree-ssa-alias.c
@@ -446,7 +446,7 @@ count_uses_and_derefs (tree ptr, tree stmt, unsigned *num_uses_p,
rhs = stmt;
}
- if (lhs && EXPR_P (lhs))
+ if (lhs && (TREE_CODE (lhs) == TREE_LIST || EXPR_P (lhs)))
{
struct count_ptr_d count;
count.ptr = ptr;
@@ -456,7 +456,7 @@ count_uses_and_derefs (tree ptr, tree stmt, unsigned *num_uses_p,
*num_derefs_p = count.count;
}
- if (rhs && EXPR_P (rhs))
+ if (rhs && (TREE_CODE (rhs) == TREE_LIST || EXPR_P (rhs)))
{
struct count_ptr_d count;
count.ptr = ptr;