]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-vrp.c (infer_value_range): Ignore asm statements when looking for memory accesse...
authorIan Lance Taylor <iant@google.com>
Thu, 24 Jul 2008 04:51:12 +0000 (04:51 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Thu, 24 Jul 2008 04:51:12 +0000 (04:51 +0000)
./: * tree-vrp.c (infer_value_range): Ignore asm statements when
looking for memory accesses for -fdelete-null-pointer-checks.
testsuite/:
* gcc.target/i386/20080723-1.c: New test.

From-SVN: r138107

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/20080723-1.c [new file with mode: 0644]
gcc/tree-vrp.c

index 82c7e61e39c06107c66a509e55b8cd01231b18c8..b032c85bbac73742954c4c632e4c79254ccc32d2 100644 (file)
@@ -1,3 +1,8 @@
+2008-07-23  Ian Lance Taylor  <iant@google.com>
+
+       * tree-vrp.c (infer_value_range): Ignore asm statements when
+       looking for memory accesses for -fdelete-null-pointer-checks.
+
 2008-07-24  Ben Elliston  <bje@au.ibm.com>
 
        * config/spu/spu-c.c (__vector_keyword): New variable.
index 5be864f133fcef942fb1c436a4778c2d8679d3a2..f4d271c3e17113eadd1f7db95e733771a9cb9fbf 100644 (file)
@@ -1,3 +1,7 @@
+2008-07-23  Ian Lance Taylor  <iant@google.com>
+
+       * gcc.target/i386/20080723-1.c: New test.
+
 2008-07-24  Ben Elliston  <bje@au.ibm.com>
 
        * gcc.target/spu/vector.c: New test.
diff --git a/gcc/testsuite/gcc.target/i386/20080723-1.c b/gcc/testsuite/gcc.target/i386/20080723-1.c
new file mode 100644 (file)
index 0000000..a2ed5bf
--- /dev/null
@@ -0,0 +1,49 @@
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+extern void abort (void);
+extern void exit (int);
+
+static inline __attribute__((always_inline))
+void
+prefetch (void *x)
+{
+  asm volatile("prefetcht0 %0" : : "m" (*(unsigned long *)x));
+}
+
+struct hlist_head
+{
+  struct hlist_node *first;
+};
+
+struct hlist_node
+{
+  struct hlist_node *next;
+  unsigned long i_ino;
+};
+
+struct hlist_node * find_inode_fast(struct hlist_head *head, unsigned long ino)
+{
+  struct hlist_node *node;
+
+  for (node = head->first;
+       node && (prefetch (node->next), 1);
+       node = node->next)
+    {
+      if (node->i_ino == ino)
+       break;
+    }
+  return node ? node : 0;
+}
+
+struct hlist_node g2;
+struct hlist_node g1 = { &g2 };
+struct hlist_head h = { &g1 };
+
+int
+main()
+{
+  if (find_inode_fast (&h, 1) != 0)
+    abort ();
+  exit (0);
+}
index 404531f45042dd65a517420289390e4b893bb750..62f314795ae0ebc9b1a0f05c533015413b11df9c 100644 (file)
@@ -3456,7 +3456,9 @@ infer_value_range (tree stmt, tree op, enum tree_code *comp_code_p, tree *val_p)
 
   /* We can only assume that a pointer dereference will yield
      non-NULL if -fdelete-null-pointer-checks is enabled.  */
-  if (flag_delete_null_pointer_checks && POINTER_TYPE_P (TREE_TYPE (op)))
+  if (flag_delete_null_pointer_checks
+      && POINTER_TYPE_P (TREE_TYPE (op))
+      && TREE_CODE (stmt) != ASM_EXPR)
     {
       unsigned num_uses, num_loads, num_stores;